Created
May 30, 2015 09:01
-
-
Save Streemo/cbf5368ccea1a3bf061a to your computer and use it in GitHub Desktop.
do i need to delete the reference before reassingning a value to the key?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//all of this code is in a function. | |
var docs = Meals.aggregate(pipeline) | |
var oldData = Cache.regulars.data | |
var newData = {}; | |
docs.forEach(function(doc){ | |
var id = doc._id | |
var raw = _.omit(doc,'_id'); | |
newData[id] = raw | |
var oldDoc = oldData[id] | |
if (oldDoc && (raw.score.total-oldDoc.score.total)){ | |
self.changed('regulars',id,{score:raw.score}) | |
} else { | |
self.added('regulars',id,raw); | |
} | |
}) | |
delete Cache.regulars.data; | |
Cache.regulars.data = newData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment