Fix target type for array loader

v2
Nikita Tokarchuk 6 years ago
parent 0d5d18437e
commit 11d202fa33
  1. 5
      mongox/common/loadarray.go

@ -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)

Loading…
Cancel
Save