|
|
@ -32,15 +32,16 @@ func LoadArray(db *mongox.Database, target interface{}, filters ...interface{}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
composed := query.Compose(filters...) |
|
|
|
composed := query.Compose(filters...) |
|
|
|
|
|
|
|
zeroElem := reflect.Zero(targetSliceElemT) |
|
|
|
hasPreloader, _ := composed.Preloader() |
|
|
|
hasPreloader, _ := composed.Preloader() |
|
|
|
|
|
|
|
|
|
|
|
var result *mongo.Cursor |
|
|
|
var result *mongo.Cursor |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
|
|
|
|
|
|
|
|
if hasPreloader { |
|
|
|
if hasPreloader { |
|
|
|
result, err = createAggregateLoad(db, target, composed) |
|
|
|
result, err = createAggregateLoad(db, zeroElem.Interface(), composed) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result, err = createSimpleLoad(db, target, composed) |
|
|
|
result, err = createSimpleLoad(db, zeroElem.Interface(), composed) |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return errors.InternalErrorf("can't create find result: %s", err) |
|
|
|
return errors.InternalErrorf("can't create find result: %s", err) |
|
|
|