chore: change interface{} to any (#2818)
* chore: change interface{} to any
* chore: update goctl version to 1.5.0
* chore: update goctl deps
This commit is contained in:
@@ -83,7 +83,7 @@ func (mm *Model) DelCache(ctx context.Context, keys ...string) error {
|
||||
}
|
||||
|
||||
// DeleteOne deletes the document with given filter, and remove it from cache.
|
||||
func (mm *Model) DeleteOne(ctx context.Context, key string, filter interface{},
|
||||
func (mm *Model) DeleteOne(ctx context.Context, key string, filter any,
|
||||
opts ...*mopt.DeleteOptions) (int64, error) {
|
||||
val, err := mm.Model.DeleteOne(ctx, filter, opts...)
|
||||
if err != nil {
|
||||
@@ -98,27 +98,27 @@ func (mm *Model) DeleteOne(ctx context.Context, key string, filter interface{},
|
||||
}
|
||||
|
||||
// DeleteOneNoCache deletes the document with given filter.
|
||||
func (mm *Model) DeleteOneNoCache(ctx context.Context, filter interface{},
|
||||
func (mm *Model) DeleteOneNoCache(ctx context.Context, filter any,
|
||||
opts ...*mopt.DeleteOptions) (int64, error) {
|
||||
return mm.Model.DeleteOne(ctx, filter, opts...)
|
||||
}
|
||||
|
||||
// FindOne unmarshals a record into v with given key and query.
|
||||
func (mm *Model) FindOne(ctx context.Context, key string, v, filter interface{},
|
||||
func (mm *Model) FindOne(ctx context.Context, key string, v, filter any,
|
||||
opts ...*mopt.FindOneOptions) error {
|
||||
return mm.cache.TakeCtx(ctx, v, key, func(v interface{}) error {
|
||||
return mm.cache.TakeCtx(ctx, v, key, func(v any) error {
|
||||
return mm.Model.FindOne(ctx, v, filter, opts...)
|
||||
})
|
||||
}
|
||||
|
||||
// FindOneNoCache unmarshals a record into v with query, without cache.
|
||||
func (mm *Model) FindOneNoCache(ctx context.Context, v, filter interface{},
|
||||
func (mm *Model) FindOneNoCache(ctx context.Context, v, filter any,
|
||||
opts ...*mopt.FindOneOptions) error {
|
||||
return mm.Model.FindOne(ctx, v, filter, opts...)
|
||||
}
|
||||
|
||||
// FindOneAndDelete deletes the document with given filter, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter interface{},
|
||||
func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter any,
|
||||
opts ...*mopt.FindOneAndDeleteOptions) error {
|
||||
if err := mm.Model.FindOneAndDelete(ctx, v, filter, opts...); err != nil {
|
||||
return err
|
||||
@@ -128,14 +128,14 @@ func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter int
|
||||
}
|
||||
|
||||
// FindOneAndDeleteNoCache deletes the document with given filter, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndDeleteNoCache(ctx context.Context, v, filter interface{},
|
||||
func (mm *Model) FindOneAndDeleteNoCache(ctx context.Context, v, filter any,
|
||||
opts ...*mopt.FindOneAndDeleteOptions) error {
|
||||
return mm.Model.FindOneAndDelete(ctx, v, filter, opts...)
|
||||
}
|
||||
|
||||
// FindOneAndReplace replaces the document with given filter with replacement, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter interface{},
|
||||
replacement interface{}, opts ...*mopt.FindOneAndReplaceOptions) error {
|
||||
func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter any,
|
||||
replacement any, opts ...*mopt.FindOneAndReplaceOptions) error {
|
||||
if err := mm.Model.FindOneAndReplace(ctx, v, filter, replacement, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -144,14 +144,14 @@ func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter in
|
||||
}
|
||||
|
||||
// FindOneAndReplaceNoCache replaces the document with given filter with replacement, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndReplaceNoCache(ctx context.Context, v, filter interface{},
|
||||
replacement interface{}, opts ...*mopt.FindOneAndReplaceOptions) error {
|
||||
func (mm *Model) FindOneAndReplaceNoCache(ctx context.Context, v, filter any,
|
||||
replacement any, opts ...*mopt.FindOneAndReplaceOptions) error {
|
||||
return mm.Model.FindOneAndReplace(ctx, v, filter, replacement, opts...)
|
||||
}
|
||||
|
||||
// FindOneAndUpdate updates the document with given filter with update, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter interface{},
|
||||
update interface{}, opts ...*mopt.FindOneAndUpdateOptions) error {
|
||||
func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter any,
|
||||
update any, opts ...*mopt.FindOneAndUpdateOptions) error {
|
||||
if err := mm.Model.FindOneAndUpdate(ctx, v, filter, update, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -160,18 +160,18 @@ func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter int
|
||||
}
|
||||
|
||||
// FindOneAndUpdateNoCache updates the document with given filter with update, and unmarshals it into v.
|
||||
func (mm *Model) FindOneAndUpdateNoCache(ctx context.Context, v, filter interface{},
|
||||
update interface{}, opts ...*mopt.FindOneAndUpdateOptions) error {
|
||||
func (mm *Model) FindOneAndUpdateNoCache(ctx context.Context, v, filter any,
|
||||
update any, opts ...*mopt.FindOneAndUpdateOptions) error {
|
||||
return mm.Model.FindOneAndUpdate(ctx, v, filter, update, opts...)
|
||||
}
|
||||
|
||||
// GetCache unmarshal the cache into v with given key.
|
||||
func (mm *Model) GetCache(key string, v interface{}) error {
|
||||
func (mm *Model) GetCache(key string, v any) error {
|
||||
return mm.cache.Get(key, v)
|
||||
}
|
||||
|
||||
// InsertOne inserts a single document into the collection, and remove the cache placeholder.
|
||||
func (mm *Model) InsertOne(ctx context.Context, key string, document interface{},
|
||||
func (mm *Model) InsertOne(ctx context.Context, key string, document any,
|
||||
opts ...*mopt.InsertOneOptions) (*mongo.InsertOneResult, error) {
|
||||
res, err := mm.Model.InsertOne(ctx, document, opts...)
|
||||
if err != nil {
|
||||
@@ -186,13 +186,13 @@ func (mm *Model) InsertOne(ctx context.Context, key string, document interface{}
|
||||
}
|
||||
|
||||
// InsertOneNoCache inserts a single document into the collection.
|
||||
func (mm *Model) InsertOneNoCache(ctx context.Context, document interface{},
|
||||
func (mm *Model) InsertOneNoCache(ctx context.Context, document any,
|
||||
opts ...*mopt.InsertOneOptions) (*mongo.InsertOneResult, error) {
|
||||
return mm.Model.InsertOne(ctx, document, opts...)
|
||||
}
|
||||
|
||||
// ReplaceOne replaces a single document in the collection, and remove the cache.
|
||||
func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement interface{},
|
||||
func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement any,
|
||||
opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
|
||||
res, err := mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
|
||||
if err != nil {
|
||||
@@ -207,18 +207,18 @@ func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement
|
||||
}
|
||||
|
||||
// ReplaceOneNoCache replaces a single document in the collection.
|
||||
func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter, replacement interface{},
|
||||
func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter, replacement any,
|
||||
opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
|
||||
return mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
|
||||
}
|
||||
|
||||
// SetCache sets the cache with given key and value.
|
||||
func (mm *Model) SetCache(key string, v interface{}) error {
|
||||
func (mm *Model) SetCache(key string, v any) error {
|
||||
return mm.cache.Set(key, v)
|
||||
}
|
||||
|
||||
// UpdateByID updates the document with given id with update, and remove the cache.
|
||||
func (mm *Model) UpdateByID(ctx context.Context, key string, id, update interface{},
|
||||
func (mm *Model) UpdateByID(ctx context.Context, key string, id, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
res, err := mm.Model.UpdateByID(ctx, id, update, opts...)
|
||||
if err != nil {
|
||||
@@ -233,13 +233,13 @@ func (mm *Model) UpdateByID(ctx context.Context, key string, id, update interfac
|
||||
}
|
||||
|
||||
// UpdateByIDNoCache updates the document with given id with update.
|
||||
func (mm *Model) UpdateByIDNoCache(ctx context.Context, id, update interface{},
|
||||
func (mm *Model) UpdateByIDNoCache(ctx context.Context, id, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
return mm.Model.UpdateByID(ctx, id, update, opts...)
|
||||
}
|
||||
|
||||
// UpdateMany updates the documents that match filter with update, and remove the cache.
|
||||
func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update interface{},
|
||||
func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
res, err := mm.Model.UpdateMany(ctx, filter, update, opts...)
|
||||
if err != nil {
|
||||
@@ -254,13 +254,13 @@ func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update i
|
||||
}
|
||||
|
||||
// UpdateManyNoCache updates the documents that match filter with update.
|
||||
func (mm *Model) UpdateManyNoCache(ctx context.Context, filter, update interface{},
|
||||
func (mm *Model) UpdateManyNoCache(ctx context.Context, filter, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
return mm.Model.UpdateMany(ctx, filter, update, opts...)
|
||||
}
|
||||
|
||||
// UpdateOne updates the first document that matches filter with update, and remove the cache.
|
||||
func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update interface{},
|
||||
func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
res, err := mm.Model.UpdateOne(ctx, filter, update, opts...)
|
||||
if err != nil {
|
||||
@@ -275,7 +275,7 @@ func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update inter
|
||||
}
|
||||
|
||||
// UpdateOneNoCache updates the first document that matches filter with update.
|
||||
func (mm *Model) UpdateOneNoCache(ctx context.Context, filter, update interface{},
|
||||
func (mm *Model) UpdateOneNoCache(ctx context.Context, filter, update any,
|
||||
opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
|
||||
return mm.Model.UpdateOne(ctx, filter, update, opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user