fix doSave
calls to check if the document's ID is a zero value
This commit is contained in:
parent
a44b9679aa
commit
bf1dad5a22
@ -96,13 +96,15 @@ func (d *Document) Save() error {
|
|||||||
if val.Kind() == reflect.Slice {
|
if val.Kind() == reflect.Slice {
|
||||||
for i := 0; i < val.Len(); i++ {
|
for i := 0; i < val.Len(); i++ {
|
||||||
cur := val.Index(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 err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user