title: geoNear exception: 'near' field must be point
body: <p>I have run the following query successfully in the mongo shell:</p>
  
  <pre><code>db.runCommand({
      geoNear : "stores",
      near : { type : "Point", coordinates : [ -3.978, 50.777 ] },
      spherical : true,
      limit : 10
  })
  </code></pre>
  
  <p>I am trying to convert this into a mongoose query for my node service  <a href="http://mongoosejs.com/docs/api.html#model_Model.geoNear" rel="noreferrer">as shown in the docs</a>.</p>
  
  <pre><code>Store.geoNear(
      { type : "Point", coordinates : [-3.978, 50.777]}, 
      { spherical : true, limit : 10 }, 
      function (error, results, stats) {
      //do stuff with results here
  });
  </code></pre>
  
  <p>This is returning the following error:</p>
  
  <pre><code>MongoError: exception: 'near' field must be point
  </code></pre>
  
  <p>My <code>Store</code> schema is defined like this:</p>
  
  <pre><code>var storeSchema = new Schema({
      // irrelevant fields...
      locations : [
          {
              address : {
                  streetAddress : String,
                  postalCode : String
              }
              coords : {
                  type : [Number],
                  index : '2dsphere'
              }
          }
      ]
  })
  </code></pre>
  
  <p>There is only one 2dsphere index on the collection, and as I mentioned, it works through the shell, just not with mongoose.</p>
  
  <p><strong>Edit:</strong> Other things I've tried without success:</p>
  
  <p>Falling back to using mongodb native driver (same error, so I suspect it's mongodb rather than mongoose causing the problem):</p>
  
  <pre><code>Store.collection.geoNear(
      { type : "Point", coordinates : [-3.978, 50.777]}, 
      { spherical : true, limit : 10 }, 
      function (error, results, stats) {
      //do stuff with results here
  });
  </code></pre>
  
  <p>Falling back to using legacy coordinates instead of geopoints (both mongoose and native (same error)):</p>
  
  <pre><code>Store.geoNear(
      -3.978, 50.777, 
      { spherical : true, limit : 10 }, 
      function (error, results, stats) {
      //do stuff with results here
  });
  </code></pre>
  
  <p>Using runCommand from mongoose (this errors differently, saying that <code>Store.db.command</code> is not a function - the correct way to call this from mongoose would be an acceptable answer):</p>
  
  <pre><code>Store.db.command({
      geoNear : "stores",
      near : { type : "Point", coordinates : [ -3.978, 50.777 ] },
      spherical : true,
      limit : 10
  }, function(error, results){})
  </code></pre>