title: mongoose $geoNear, $near, and $nearSphere are not allowed in this context
body: <p>This is my Schema:</p>
  
  <pre><code>const userSchema = mongoose.Schema({
      coordinates: {
          type: { type: String },
          coordinates: [],
         },
  })
  </code></pre>
  
  <p>and then I add this:</p>
  
  <pre><code>userSchema.index({ coordinates: "2dsphere" });
  </code></pre>
  
  <p>I want to find all coordinates within a radius. This is the method I am calling:</p>
  
  <pre><code>router.post('/users/query', async(req,res)=&gt;{
      var pageOptions = {
          page: req.body.page || 0,
          limit:  10
      }
      const query ={     location: {
          $near: {
           $maxDistance: req.body.searchQuery.maxDistance,
           $geometry: {
            type: "Point",
            coordinates: req.body.searchQuery.coordinates
           }
          }
         }} 
         console.log(query)
      User.find(query)
      .skip(pageOptions.page*pageOptions.limit)
      .limit(pageOptions.limit)
      .exec(function (error, users) {
          if(error) { res.status(500).json({error}); return; };
          User.countDocuments(query).exec((error,total)=&gt;{
              if(error) { 
                  res.status(500).json({error})
              }else{
                  res.status(200).json({users,total});
  
               };
          })
      })
  })
  </code></pre>
  
  <p>I did it like in this articel: <a href="https://medium.com/@galford151/mongoose-geospatial-queries-with-near-59800b79c0f6" rel="nofollow noreferrer">https://medium.com/@galford151/mongoose-geospatial-queries-with-near-59800b79c0f6</a></p>
  
  <p>But I get error $geoNear, $near, and $nearSphere are not allowed in this context. somebody knows why? </p>
  
  <p>This is my searchQuery:</p>
  
  <pre><code>{ searchQuery: 
  { coordinates: [ 9.993681899999956, 53.5510846 ],
  maxDistance: 1000 } }
  </code></pre>