rework how references are found in Document.Populate

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-04-10 16:09:40 -04:00
parent f56df39be8
commit 0ebe3a2a3a
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -301,9 +301,9 @@ func (d *Document) Populate(fields ...string) {
for _, field := range fields {
// 0 = fieldname, 1 = typename, 2 = bson name
r, _ := readFields(field, cm)
r, refOk := cm.references[field]
if r.exists {
if refOk {
// get self
// get ptr
// find
@ -328,8 +328,11 @@ func (d *Document) Populate(fields ...string) {
asIDocument.markPopulated(field)
}
tmp1 = populate(r, refColl.collection, rawDoc, field, reflect.ValueOf(d.self).Interface())
d.self = tmp1
v := reflect.ValueOf(d.self)
tt := v.Elem().Type()
tmp1 = populate(r, refColl.collection, rawDoc, field, d.self)
nv := reflect.NewAt(tt, v.UnsafePointer())
nv.Elem().Set(reflect.ValueOf(tmp1).Elem())
}
}
}