You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I may be the one making a mistake here but according to this library's source code and unit tests, sub-docs pagination must return not only docs but pagination results properties such as totalDocs, totalPages, prevPage etc.
In my case, normal pagination works correctly as I can see those properties but once I try to use sub-docs pagination something bizarre happens. Populated field only returns documents but those documents are not stored in "docs" property and returned field doesn't have any pagination result property. It only paginates the populated field and that is it.
Here is a example code:
let page = 1;
let limit= 10;
const option = {
pagingOptions: {
populate: {
path: "products",
},
page: page,
limit: limit,
},
};
let result = await Category.paginateSubDocs(
{ slug: req.params.slug },
option,
);
In above code result object returns like this:
result = {
"_id": *normal id here*
"name": "phones"
"slug": "phones"
"products": [
{
"_id": *normal id here*
"name": "name"
"price": 555
}]
}
Like I said before pagination works in above case. If you enter another page number it returns docs that only found in that page but not any pagination result properties.
Expected behavior
Instead result object should return like this:
result = {
"_id": *normal id here*
"name": "phones"
"slug": "phones"
"products":
{
"docs": *products doc array here*
"totalDocs": 20
"totalPages": 2
**and rest of the pagination result properties here**
}
}
Desktop and library versions:
OS: Windows 10 22H2
Node version: 22.13.0
mongoose version: 8.9.5 (Tried 8.0.0, problem still persists)
mongoose-paginate-v2 version: 1.9.0
The text was updated successfully, but these errors were encountered:
Description
I may be the one making a mistake here but according to this library's source code and unit tests, sub-docs pagination must return not only docs but pagination results properties such as totalDocs, totalPages, prevPage etc.
In my case, normal pagination works correctly as I can see those properties but once I try to use sub-docs pagination something bizarre happens. Populated field only returns documents but those documents are not stored in "docs" property and returned field doesn't have any pagination result property. It only paginates the populated field and that is it.
Here is a example code:
In above code result object returns like this:
Like I said before pagination works in above case. If you enter another page number it returns docs that only found in that page but not any pagination result properties.
Expected behavior
Instead result object should return like this:
Desktop and library versions:
The text was updated successfully, but these errors were encountered: