Clear any overlap when using Mongo's $unset operator
This commit is contained in:
1 parent
5fd869c6b9
commit
12a6cd7d8b
1 file changed
+3
@@ -538,6 +538,9 @@ saveDevice = (deviceId, deviceData, isNew, callback) ->
|
|||||||
|
|
||||||
return callback() if Object.keys(update).length == 0
|
return callback() if Object.keys(update).length == 0
|
||||||
|
|
||||||
|
if (update['$unset']?)
|
||||||
|
optimizeProjection(update['$unset'])
|
||||||
|
|
||||||
devicesCollection.update({'_id' : deviceId}, update, {upsert: isNew}, (err, result) ->
|
devicesCollection.update({'_id' : deviceId}, update, {upsert: isNew}, (err, result) ->
|
||||||
if not err and result.result.n != 1
|
if not err and result.result.n != 1
|
||||||
return callback(new Error("Device #{deviceId} not found in database"))
|
return callback(new Error("Device #{deviceId} not found in database"))
|
||||||
|
|||||||
Reference in new issue
Block a user