@@ -33,7 +33,22 @@ func NewMongoLoader(db *mongo.Database, collectionName string, modelType reflect
33
33
func NewLoader (db * mongo.Database , collectionName string , modelType reflect.Type , options ... func (context.Context , interface {}) (interface {}, error )) * Loader {
34
34
return NewMongoLoader (db , collectionName , modelType , false , options ... )
35
35
}
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
+ }
37
52
func (m * Loader ) Id () string {
38
53
return m .jsonIdName
39
54
}
0 commit comments