title: Pass variables to mongodb query in nodejs
body: <p>Can I pass a variable to a query so:</p>
  
  <pre><code>db.collection('coll').find(query).toArray(function(err, docs) {
      if(err) throw err;
      docs.forEach(function(doc) {
          var Id = parseInt(doc._id); // a returnd _id from previous query
          Id--;
          query = {_id : parseInt(doc._id) }; // returns null
          // OR query = {_id : Id }; // error
          db.collection('coll').find(query).toArray(function(err, beforeDocs) {
              //if (err) throw err;
              console.dir(beforeDocs);
          });
  });
  </code></pre>
  
  <p>In fact what I am trying to do is query by id to get the record that comes before the results given in the first query</p>
  
  <p>Any ideas??</p>
  
  <p>Is it at all possible to query mongodb with variables??</p>
  
  <p><code>var query = { _id : var i, name : var name , etc...}</code></p>