mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-07-03 17:22:33 +00:00
Fix loadarray slice offset
This commit is contained in:
@@ -48,19 +48,17 @@ func LoadArray(db *mongox.Database, target interface{}, filters ...interface{})
|
|||||||
defer result.Close(db.Context())
|
defer result.Close(db.Context())
|
||||||
var i int
|
var i int
|
||||||
|
|
||||||
for i = 0; result.Next(db.Context()); i++ {
|
for i = 0; result.Next(db.Context()); {
|
||||||
if targetSliceV.Len() == i {
|
if targetSliceV.Len() == i {
|
||||||
elem := reflect.New(targetSliceElemT.Elem())
|
elem := reflect.New(targetSliceElemT.Elem())
|
||||||
if result.Decode(elem.Interface()) != nil {
|
if result.Decode(elem.Interface()) != nil {
|
||||||
continue
|
targetSliceV = reflect.Append(targetSliceV, elem)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
targetSliceV = reflect.Append(targetSliceV, elem)
|
result.Decode(targetSliceV.Index(i).Interface())
|
||||||
// currentv = currentv.Slice(0, currentv.Cap())
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Decode(targetSliceV.Index(i).Interface())
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
targetSliceV = targetSliceV.Slice(0, i)
|
targetSliceV = targetSliceV.Slice(0, i)
|
||||||
|
|||||||
Reference in New Issue
Block a user