Skip to content

Instantly share code, notes, and snippets.

@yamadapc
Created September 22, 2015 22:10
Show Gist options
  • Save yamadapc/9fffb15e163308cc273e to your computer and use it in GitHub Desktop.
Save yamadapc/9fffb15e163308cc273e to your computer and use it in GitHub Desktop.
var ONE_WEEK = 60 * 60 * 24 * 7
function updateShortCycles(collection) {
var query = 'this.cycle && this.cycle.cycle_seconds < ' + ONE_WEEK;
print('Querying ' + collection + '"' + query + '"');
collection.find(query).forEach(function(doc) {
print('Updating ' + collection + ' ' + doc._id);
collection.update(
{ _id: doc._id},
{ $set : { "cycle.cycle_seconds" : '' + ONE_WEEK } }
);
});
}
updateShortCycles(db.subscriptions);
updateShortCycles(db.offers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment