Skip to content

Instantly share code, notes, and snippets.

@pqwy
Created October 31, 2012 17:29
Show Gist options
  • Save pqwy/3988500 to your computer and use it in GitHub Desktop.
Save pqwy/3988500 to your computer and use it in GitHub Desktop.
index occurrence ids
// nb. we have a typo with occurrences -- sometimes they are called "occurences".
var filter = {};
var projection = {
_id : true,
facebook_occurence_ids : true
};
db.movies.find(filter, projection)
.forEach(function (movie) {
var x = ( movie.facebook_occurence_ids || [] ).length;
db.movies.update( { _id: movie._id }, { '$set': { occurrence_count: x } } );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment