Skip to content

Instantly share code, notes, and snippets.

@lkosak
Created September 21, 2011 18:18
Show Gist options
  • Save lkosak/1232860 to your computer and use it in GitHub Desktop.
Save lkosak/1232860 to your computer and use it in GitHub Desktop.
db.events.find({"name":"purchased_deal","is_first_time":{$exists:false}}).forEach(function(data) {
 var query = {
     "name" : data.name,
     "user_id" : data.user_id,
"date_created": { $lt : data.date_created }
   }
if(db.events.count(query) == 0) {
data.is_first_time = true
} else {
data.is_first_time = false
}
db.events.save(data)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment