ensure we set each document's Model on find
This commit is contained in:
parent
7fc4ed46c8
commit
e6a83d12e3
11
model.go
11
model.go
@ -118,12 +118,16 @@ func (m *Model) Find(query interface{}, opts *options.FindOptionsBuilder) (*Quer
|
||||
if err == nil {
|
||||
idoc.setExists(true)
|
||||
}
|
||||
|
||||
qq.rawDoc = rawRes
|
||||
err = q.All(context.TODO(), &qq.doc)
|
||||
if err != nil {
|
||||
qq.reOrganize()
|
||||
err = nil
|
||||
}
|
||||
for _, doc := range *idoc {
|
||||
doc.setModel(*m)
|
||||
}
|
||||
}
|
||||
|
||||
return qq, err
|
||||
@ -160,9 +164,6 @@ func (m *Model) FindOne(query interface{}, options *options.FindOneOptionsBuilde
|
||||
}
|
||||
qqn := ModelRegistry.new_(m.typeName)
|
||||
idoc, ok := qqn.(IDocument)
|
||||
if ok {
|
||||
idoc.setExists(true)
|
||||
}
|
||||
|
||||
qq := &Query{
|
||||
collection: m.getColl(),
|
||||
@ -177,6 +178,10 @@ func (m *Model) FindOne(query interface{}, options *options.FindOneOptionsBuilde
|
||||
qq.reOrganize()
|
||||
err = nil
|
||||
}
|
||||
if ok {
|
||||
idoc.setExists(true)
|
||||
idoc.setModel(*m)
|
||||
}
|
||||
idoc.setSelf(idoc)
|
||||
return qq, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user