@ -19,6 +19,11 @@ type Loader interface {
Load(db *Database, filters ...interface{}) error
}
// Resetter is an interface for documenta that can be resetted
type Resetter interface {
Reset()
// BaseObjectID is an interface for documents that have objectId type for the _id field
type BaseObjectID interface {
GetID() primitive.ObjectID
@ -25,6 +25,11 @@ func (l *ManyLoader) Get() error {
return errors.NotFoundErrorf("%s", mongo.ErrNoDocuments)
resettable, canReset := l.target.(mongox.Resetter)
if canReset {
resettable.Reset()
err := l.Decode(l.target)
if err != nil {
return errors.InternalErrorf("can't decode desult: %s", err)