Compare commits
No commits in common. "0ebe3a2a3a5290c1bfb5ead27d74c33ee9f8f8e2" and "510a126f4ba5bcf7398b59b9b3c8013a425f03a2" have entirely different histories.
0ebe3a2a3a
...
510a126f4b
11
document.go
11
document.go
@ -301,9 +301,9 @@ func (d *Document) Populate(fields ...string) {
|
|||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
// 0 = fieldname, 1 = typename, 2 = bson name
|
// 0 = fieldname, 1 = typename, 2 = bson name
|
||||||
|
|
||||||
r, refOk := cm.references[field]
|
r, _ := readFields(field, cm)
|
||||||
|
|
||||||
if refOk {
|
if r.exists {
|
||||||
// get self
|
// get self
|
||||||
// get ptr
|
// get ptr
|
||||||
// find
|
// find
|
||||||
@ -328,11 +328,8 @@ func (d *Document) Populate(fields ...string) {
|
|||||||
asIDocument.markPopulated(field)
|
asIDocument.markPopulated(field)
|
||||||
}
|
}
|
||||||
|
|
||||||
v := reflect.ValueOf(d.self)
|
tmp1 = populate(r, refColl.collection, rawDoc, field, reflect.ValueOf(d.self).Interface())
|
||||||
tt := v.Elem().Type()
|
d.self = tmp1
|
||||||
tmp1 = populate(r, refColl.collection, rawDoc, field, d.self)
|
|
||||||
nv := reflect.NewAt(tt, v.UnsafePointer())
|
|
||||||
nv.Elem().Set(reflect.ValueOf(tmp1).Elem())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
query.go
8
query.go
@ -611,18 +611,10 @@ func (q *Query) Exec(result interface{}) {
|
|||||||
imodel, ok := cur.Interface().(IDocument)
|
imodel, ok := cur.Interface().(IDocument)
|
||||||
if ok {
|
if ok {
|
||||||
imodel.setExists(true)
|
imodel.setExists(true)
|
||||||
imodel.SetSelf(imodel)
|
|
||||||
doc.Elem().Index(i).Set(reflect.ValueOf(imodel))
|
doc.Elem().Index(i).Set(reflect.ValueOf(imodel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if idoc, ok := q.doc.(IDocument); ok {
|
|
||||||
idoc.SetSelf(result)
|
|
||||||
}
|
|
||||||
if rdoc, ok2 := result.(IDocument); ok2 {
|
|
||||||
rdoc.SetSelf(result)
|
|
||||||
}
|
|
||||||
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(q.doc).Elem())
|
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(q.doc).Elem())
|
||||||
q.done = true
|
q.done = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user