Allow setting fields previously unset, like adding a connection when it was nil in db

This commit is contained in:
breel
2020-07-26 02:37:02 -06:00
parent 962a0b0585
commit 363d3143e8
5 changed files with 91 additions and 3 deletions

View File

@@ -288,7 +288,8 @@ func applyUnset(doc, operator bson.M) (bson.M, error) {
if len(nesting) > 1 {
mInterface, ok := doc[nesting[0]]
if !ok {
return nil, fmt.Errorf("path does not exist: %s (%s): %+v", k, nesting[0], doc)
continue
//return nil, fmt.Errorf("path does not exist: %s (%s): %+v", k, nesting[0], doc)
}
m, ok := mInterface.(map[string]interface{})
if !ok {
@@ -320,7 +321,8 @@ func applySet(doc, operator bson.M) (bson.M, error) {
if len(nesting) > 1 {
mInterface, ok := doc[nesting[0]]
if !ok {
return nil, fmt.Errorf("path does not exist: %s (%s): %+v", k, nesting[0], doc)
mInterface = map[string]interface{}{}
//return nil, fmt.Errorf("path does not exist: %s (%s): %+v", k, nesting[0], doc)
}
m, ok := mInterface.(map[string]interface{})
if !ok {