Skip to content

Commit e46a24a

Browse files
committed
Add UseGet
1 parent 8f80c83 commit e46a24a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

loader.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,22 @@ func NewMongoLoader(db *mongo.Database, collectionName string, modelType reflect
3333
func NewLoader(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) *Loader {
3434
return NewMongoLoader(db, collectionName, modelType, false, options...)
3535
}
36-
36+
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) {
37+
l := NewMongoLoader(db, collectionName, modelType, idObjectId, options...)
38+
return l.LoadAndDecode
39+
}
40+
func Load(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
41+
return UseMongoLoad(db, collectionName, modelType, false, options...)
42+
}
43+
func UseLoad(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
44+
return UseMongoLoad(db, collectionName, modelType, false, options...)
45+
}
46+
func UseGet(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
47+
return UseMongoLoad(db, collectionName, modelType, false, options...)
48+
}
49+
func Get(db *mongo.Database, collectionName string, modelType reflect.Type, options ...func(context.Context, interface{}) (interface{}, error)) func(context.Context, interface{}, interface{}) (bool, error) {
50+
return UseMongoLoad(db, collectionName, modelType, false, options...)
51+
}
3752
func (m *Loader) Id() string {
3853
return m.jsonIdName
3954
}

0 commit comments

Comments
 (0)