Skip to content

Commit

Permalink
Add UseGet
Browse files Browse the repository at this point in the history
  • Loading branch information
minhduc140583 committed Mar 19, 2022
1 parent 8f80c83 commit e46a24a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,22 @@ func NewMongoLoader(db *mongo.Database, collectionName string, modelType reflect
func NewLoader(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) *Loader {
return NewMongoLoader(db, collectionName, modelType, false, options...)
}

func UseMongoLoad(db *mongo.Database, collectionName string, modelType reflect.Type, idObjectId bool, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
l := NewMongoLoader(db, collectionName, modelType, idObjectId, options...)
return l.LoadAndDecode
}
func Load(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
return UseMongoLoad(db, collectionName, modelType, false, options...)
}
func UseLoad(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
return UseMongoLoad(db, collectionName, modelType, false, options...)
}
func UseGet(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
return UseMongoLoad(db, collectionName, modelType, false, options...)
}
func Get(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
return UseMongoLoad(db, collectionName, modelType, false, options...)
}
func (m *Loader) Id() string {
return m.jsonIdName
}
Expand Down

0 comments on commit e46a24a

Please sign in to comment.