mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Add reset to other load functions
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/mainnika/mongox-go-driver/mongox"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/base"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/errors"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/query"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@@ -58,8 +59,12 @@ func LoadArray(db *mongox.Database, target interface{}, filters ...interface{})
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
} else if err = result.Decode(targetSliceV.Index(i).Interface()); err != nil {
|
||||
continue
|
||||
} else {
|
||||
elem := targetSliceV.Index(i).Interface()
|
||||
base.Reset(elem)
|
||||
if err = result.Decode(elem); err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
i++
|
||||
|
||||
@@ -2,6 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"github.com/mainnika/mongox-go-driver/mongox"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/base"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/errors"
|
||||
"github.com/mainnika/mongox-go-driver/mongox/query"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@@ -30,5 +31,7 @@ func LoadOne(db *mongox.Database, target interface{}, filters ...interface{}) er
|
||||
return errors.NotFoundErrorf("can't find result: %s", result.Err())
|
||||
}
|
||||
|
||||
base.Reset(target)
|
||||
|
||||
return result.Decode(target)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user