mongoose virtual populate returnCount option
See original GitHub issueI am using mongoose v4.5.3
I am guessing, virtual populate method use find
to populate data or findOne
method when justOne
is set to true. Can you please add returnCount
option when it uses count
query and populate document count?
Or please guide me to make the changes by myself so that I could give you a PR.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Mongoose Populate Virtual Option Count returns whole ...
The mongoose populate virtual count is supposed to return the total number of documents that satisfies the ref, localField and foreignField. But ...
Read more >Mongoose v6.8.2: Query Population
Arrays of refs work the same way. Just call the populate method on the query and an array of documents will be returned...
Read more >Populating virtual count field returns the sum of all referencing ...
It returns total number of references in the reference array (replies) instead of number of reports for those referenced replies. Version of ...
Read more >Using MongoDB with Mongoose — Populate Virtuals and Count
In this article, we'll look at how to use Mongoose to manipulate our MongoDB database. Populate Virtuals: The Count Option. We can add...
Read more >The deep virtual population in mongoose is actually very simple!
mongoose's virtual population is very useful tool. ... it has second parameter which returns the populate documents, original documents also get changed.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Will add this for 5.4 👍
I indeed like this feature. I’m building a restful api system that responses all data by calling a single request. But the limitation is that mongoose cannot return the count of the population field. It leads to the difficulty of paging because we don’t know the total records of populated objects. Without this, I must call some queries to just get the total records.
It’s very great if mongoose has an option that can choose returning only data, only count or both.
For example:
Only data:
Only count:
Or both: