if you want to count a all users in users try
On Wednesday, July 16, 2014 11:40:54 AM UTC-4, dessa beca GP wrote:
users.count({}, function(err, result){
});
or you can chain it after a find
users.find().count(function( err, count){
});
On Wednesday, July 16, 2014 11:40:54 AM UTC-4, dessa beca GP wrote:
I am trying to count all Documents in a Collection but I just get 'undefined '.
I searched in Mongoose Documentation but the only example that I have is this :users.count(query , function(err, result){
if(err) ...
// count is the result
var count = result
});So, in Mongoose Documentation I can count the number of documents that match a query passed in the function, butHow can I count all the Documents in a Collection? All without any query?In Mongoose terminal I can just do :db.CollectionName.count()
Does someone know how to do it using Mongoose?Thank you.
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/
Google Groups - https://groups.google.com/
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
댓글 없음:
댓글 쓰기