fix doSave calls to check if the document's ID is a zero value

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-03-26 23:25:44 -04:00
parent a44b9679aa
commit bf1dad5a22
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -96,13 +96,15 @@ func (d *Document) Save() error {
if val.Kind() == reflect.Slice {
for i := 0; i < val.Len(); i++ {
cur := val.Index(i)
if err := doSave(d.model.getColl(), !d.exists, cur.Interface()); err != nil {
asId := cur.Interface().(HasID)
if err := doSave(d.model.getColl(), !d.exists && reflect.ValueOf(asId.Id()).IsZero(), cur.Interface()); err != nil {
return err
}
}
return nil
} else {
return doSave(d.model.getColl(), !d.exists, d.self)
asId := val.Interface().(HasID)
return doSave(d.model.getColl(), !d.exists && reflect.ValueOf(asId.Id()).IsZero(), d.self)
}
}