nlr_p nlr_p - 1 year ago 110
Node.js Question

How to get data and count in one query in mongoose

I tried to get notification as well as the data in one query and i tried like below but this is giving only count,

Categories.find(item).count().exec(function (err, result) {}

Can anyone please suggest help.

Answer Source

You can't get your data like this way as @adeneo said in the comment.

Use find to get all records and then check length of records

Categories.find({query},function (err, result) {
       var count=result.length;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download