How to count the number of documents in a mongodb collection

前端 未结 8 1989
广开言路
广开言路 2020-12-29 04:49

I would like to know how to count the number of documents in a collection. I tried the follow

var value = collection.count();
&&
var value = collecti         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 05:23

    db.collection.count(function(err,countData){
    
    //you will get the count of number of documents in mongodb collection in the variable 
    countdata
    
    });
    

    In place of collection give your mongodb collection name

提交回复
热议问题