title: MongoDB: how to update n records based on ObjectID
body: <p>I've created a Collection containing 1 million documents, and I'm trying to select 50000 of these records based on the ObjectID, and update one of the values (i'm working in Mongo shell, running on Ubuntu).</p>
  
  <p>Is it possible to define a 50000 document range? It doesn't matter which documents are included in the 50000 range, I simply want to ringfence a definite number of records and run an update operation using the primary id so that I can measure the performance time.</p>
  
  <p>The code I've tried to run doesn't work:</p>
  
  <pre><code>  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));
  </code></pre>
  
  <p>...i'm gathering that MongoDB needs me to include a query in the command to specify which docs are to be updated (I now understand from reading other posts that .limit won't constrain the number of records than an .update writes to).</p>
  
  <p>Please can anyone advise a method that'll enable me to define the number of records to be updated?</p>
  
  <p>Grateful for advice.</p>
  
  <p>R,
  Jon </p>