I am currently working in the Mongo shell on Ubuntu and have a Collection with 1 million documents. My goal is to select 50,000 records based on their ObjectID and update one of the values.
Is there a way to specify a range of 50,000 documents for the update operation? The exact selection of documents within this range isn't important, I just need to isolate this number of records to measure performance time when updating using the primary id.
I attempted to run the following code without success:
use Assignment
var _start = new Date()
db.FlightsDate.update({$set:{Airtime: 8888}}).limit(50000).hint({_id:1});
var _end = new Date();
print("Time to Bulk Update AirTime key for 50000 documents… " + ((_end - _start)/1000));
It seems that MongoDB requires a query to be included in the command to specify which documents should be updated. I now understand from other sources that the .limit method might not limit the number of records updated by an .update operation.
If anyone can suggest a method to define the number of records to update, I would greatly appreciate it.
Thank you for your advice.
Best regards, Jon