leodinas-hao / mongoose-query-parser

Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, string template, type casting and many more...
MIT License
68 stars 17 forks source link

Populate fields inside an array of objects #25

Closed luizsandoval closed 2 years ago

luizsandoval commented 2 years ago

Hello,

I have a data structure as follows:

image

Where fields is an array of objects containing a field that is an ObjectId that references to another collection.

I'm trying to populate fields.field using the nested populate syntax populate=fields.field, but mongoose-query-parser outputs the following:

image

When what I really want is:

{
     populate: [
          {
              path: 'fields.field'
          }
     ]
}

Am I doing something wrong? Can this feature be implemented?

Best regards,

Luiz Sandoval.

luizsandoval commented 2 years ago

I found out my mongoose schema was wrong.