Commit 05758888 by Feanil Patel

Use bulk operation instead.

The bulk operation should be faster and more performant than doing the db.find.update

Docs here: http://docs.mongodb.org/v2.6/reference/method/Bulk.find.update/
parent 1dff2db4
...@@ -3,9 +3,7 @@ db.contents.ensureIndex({ _type: 1, course_id: 1, context: 1, pinned: -1, create ...@@ -3,9 +3,7 @@ db.contents.ensureIndex({ _type: 1, course_id: 1, context: 1, pinned: -1, create
db.contents.ensureIndex({ _type: 1, commentable_id: 1, context: 1, pinned: -1, created_at: -1 }, {background: true}) db.contents.ensureIndex({ _type: 1, commentable_id: 1, context: 1, pinned: -1, created_at: -1 }, {background: true})
print ("Adding context to all comment threads where it does not yet exist\n"); print ("Adding context to all comment threads where it does not yet exist\n");
db.contents.update( var bulk = db.contents.initializeUnorderedBulkOp();
{_type: "CommentThread", context: {$exists: false}}, bulk.find( {_type: "CommentThread", context: {$exists: false}} ).update( {$set: {context: "course"}} );
{$set: {context: "course"}}, bulk.execute();
{multi: true}
);
printjson (db.runCommand({ getLastError: 1, w: "majority", wtimeout: 5000 } )); printjson (db.runCommand({ getLastError: 1, w: "majority", wtimeout: 5000 } ));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment