aravindnc / mongoose-paginate-v2

A custom pagination library for Mongoose with customizable labels.

Home Page:https://www.npmjs.com/package/mongoose-paginate-v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to find by subdocument

kaboume opened this issue · comments

commented

Hi,

I have a collection of "stages" and each stage contains an adress as a subdocument.

issue

I want to find all the stages that match with a specific region. So i wrote :

  const filter = {}

  if (req.query.region && req.query.region.length > 0) {
    filter.adresse = { region: req.query.region };
  }
  const options = pick(req.query, ['sortBy', 'limit', 'page']);
  const result = await stageService.queryStages(filter, options);

But this filter doesn't work.

Same issue

commented

Any idea ?