Change preloader query function interface

v2
Nikita Tokarchuk 4 years ago
parent 84ae518fe9
commit eeb1a8d598
No known key found for this signature in database
GPG Key ID: DBFD964471BAE65C
  1. 2
      mongox/database/database.go
  2. 2
      mongox/database/loadarray.go
  3. 2
      mongox/database/loadone.go
  4. 2
      mongox/database/loadstream.go
  5. 4
      mongox/query/query.go

@ -129,7 +129,7 @@ func (d *Database) createAggregateLoad(target interface{}, composed *query.Query
el := reflect.ValueOf(target).Elem()
elType := el.Type()
numField := elType.NumField()
_, preloads := composed.Preloader()
preloads, _ := composed.Preloader()
for i := 0; i < numField; i++ {

@ -37,7 +37,7 @@ func (d *Database) LoadArray(target interface{}, filters ...interface{}) (err er
}
zeroElem := reflect.Zero(targetSliceElemT)
hasPreloader, _ := composed.Preloader()
_, hasPreloader := composed.Preloader()
ctx := query.WithContext(d.Context(), composed)
var result *mongox.Cursor

@ -16,7 +16,7 @@ func (d *Database) LoadOne(target interface{}, filters ...interface{}) (err erro
return
}
hasPreloader, _ := composed.Preloader()
_, hasPreloader := composed.Preloader()
ctx := query.WithContext(d.Context(), composed)
var result *mongox.Cursor

@ -15,7 +15,7 @@ func (d *Database) LoadStream(target interface{}, filters ...interface{}) (loade
return
}
hasPreloader, _ := composed.Preloader()
_, hasPreloader := composed.Preloader()
ctx := query.WithContext(d.Context(), composed)
var cursor *mongox.Cursor

@ -76,10 +76,10 @@ func (q *Query) Updater() (update primitive.A) {
}
// Preloader is a preloader list for a query
func (q *Query) Preloader() (ok bool, preloads []string) {
func (q *Query) Preloader() (preloads []string, ok bool) {
if q.preloader == nil {
return false, nil
return nil, false
}
preloads = q.preloader.Preload()

Loading…
Cancel
Save