title: MongoError: query selector must be an object
body: <p>I am trying to dynamically build a query, I can build it and copy and paste it straight into the console and it works.</p>
  
  <p>It seems that the query is not recognised as an object which is where I am stuck:(</p>
  
  <p>Is there a way that I can convert the <code>query</code> string into an obbject that mongodb can recognise?</p>
  
  <p>This is used in nodejs 6.10</p>
  
  <pre><code>var string = "tag1,tag2".split(",").map(function (a) { return new RegExp('^' + a) }).join(", ");
  
  var query = '{ "optionsSearch": { "$all": [ ' + string + ' ] } }';
  
  // this is my desired query below, if I copy and paste this straight into the query it works? 
  
  console.log(query);  ///&lt;- { "optionsSearch": { "$all": [ /^tag1/, /^tag2/ ] } } 
  
  mongodb.MongoClient.connect('mongodb://*******:*****@aws-eu-west-1-portal#####', function (err, db) {
  
  console.log("Connected to mongo");
  
  var minidealers = db.collection('collection1');
  
  minidealers.find(query) //&lt;- FAILS MongoError: query selector must be an object
      .limit(100)
      .toArray(function (err, items) {
          console.log(items);
      });
  });
  </code></pre>