Fixed bug where refreshObject does not remove from database parameters that don't exist anymore in the device data model.

This commit is contained in:
Zaid Abdulla committed 2014-09-05 16:01:47 +03:00
1 parent 233daee88f
commit 6afe793c52
1 file changed
+2 -2
+2 -2
View File
@@ -187,7 +187,7 @@ commitUpdates = (deviceId, deviceUpdates, commitQueue, callback) ->
if presentPaths[p] if presentPaths[p]
recursive(v, "#{p}.") recursive(v, "#{p}.")
else else
update['$unset'][p] = 1 update['$unset'][p] = 2
# Scan the DB object and remove parameters that no longer exists in device # Scan the DB object and remove parameters that no longer exists in device
for path of projection for path of projection
@@ -202,7 +202,7 @@ commitUpdates = (deviceId, deviceUpdates, commitQueue, callback) ->
recursive(root, rootPath) recursive(root, rootPath)
else else
if not presentPaths[rootPath.slice(0, -1)]? if not presentPaths[rootPath.slice(0, -1)]?
update['$unset'][rootPath.slice(0, -1)] = 1 update['$unset'][rootPath.slice(0, -1)] = 2
# Remove unnecessary unset updates # Remove unnecessary unset updates
for k, v of update['$unset'] for k, v of update['$unset']