ExtraBB / typegoose-cursor-pagination

A mongoose plugin for cursor pagination with typegoose support
MIT License
17 stars 10 forks source link

$geoNear is not allowed in query object #30

Closed alimoli closed 2 years ago

alimoli commented 2 years ago

I would like to paginate something very easy like the following find call using this library.

const docs = await MyModel.find({
    location: {
      $nearSphere: {
        $geometry: {
          type: "Point",
          coordinates: [location?.latitude, location?.longitude]
        }
      }
    }
  })

Using this library:

  const { docs, hasNext, next } = await MerchantModel.findPaged({
    limit: pagination?.first || undefined,
    next: pagination?.after || undefined
  }, {
    location: {
      $near: {
        $geometry: {
          type: "Point",
          coordinates: [location?.latitude, location?.longitude]
        }
      }
    }
  })

However, using findPaged I get the following error: $geoNear, $near, and $nearSphere are not allowed in this context.

ExtraBB commented 2 years ago

I have updated all dependencies, can you check if this is now fixed?