title: mongodb GeoJSON coordinates must be an array
body: <p>There's a requirement to search some locations in a given region. And here is an example of my test data in mongo:</p>
  <pre><code>{
  &quot;_id&quot; : &quot;insititution_NPqTrcysjKV&quot;,
  &quot;phone&quot; : &quot;18080808088&quot;,
  &quot;name&quot; : &quot;Insititution 1&quot;,
  &quot;address&quot; : &quot;xxxxxxxxxxxxx&quot;,
  &quot;city&quot; : &quot;New York&quot;,
  &quot;location&quot; : {
      &quot;type&quot; : &quot;Point&quot;,
      &quot;coordinates&quot; : [ 
          121.62764, 
          29.89805
      ]
  },
  &quot;includeLessions&quot; : [ 
      &quot;English&quot;
  ]
  }
  </code></pre>
  <p>I've got a list of such entries in my mongodb. and here goes my query in Robo3T:</p>
  <pre><code>db.Insititution.find(
  {
   location: {
     $geoIntersects: {
        $geometry: {
           type: &quot;Polygon&quot; ,
           coordinates: [
             [ [ 121.33, 29.899 ], [ 121.33, 29.770 ], [ 121.67, 29.770 ], [ 121.67, 29.899 ], [ 121.33, 29.899 ] ]
           ]
        }
     }
   }
   }
   )
  </code></pre>
  <p>It's works in robo3t, but in my project, I did like this:</p>
  <pre><code>    var where = {
        location: {
          $geoIntersects: {
            $geometry: {
              type: &quot;Polygon&quot;,
              coordinates: [
                [longitudeMin, latitudeMin],
                [longitudeMin, latitudeMax],
                [longitudeMax, latitudeMax],
                [longitudeMax, latitudeMin],
                [longitudeMin, latitudeMin]
              ]
            }
          }
        }
      }
      return promiseUtils.mongoNativeFindPromise(this.modelName, where);
  
  
    // function in promiseUtils:
    exports.mongoNativeFindPromise = async function (modelName, where, options) {
    const db = await MongoClient.connect(uri);
    try {
      let collection = db.db(mongoDBSettings.database);
      var cusor = await collection.collection(modelName).find(where, options);
      return await cusor.toArray();
    } catch (err) {
      throw err;
    } finally {
      db.close();
    }
  };
  </code></pre>
  <p>and this is exactly what the 'where' variable goes like when run the code:
  <a href="https://i.stack.imgur.com/cxdnh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cxdnh.png" alt="enter image description here" /></a>
  but mongo return an error:  GeoJSON coordinates must be an array
  Can anybody help?</p>