【发布时间】:2019-11-11 17:04:53
【问题描述】:
如何获取文件数 find total express js?我在谷歌和 StackOverflow 中搜索过。但我找不到。人们说的是使用countDocuments 来获取模型的文档数量,如下所示:
UserModel.countDocuments(function(err,count){
count
res.render('index',{count:count}); // returning count and rendering to index.ejs
});
但我想要同时得到结果集和recordcount,如下所示
UserModel.find(function(err,data){
res.render('index',{data:data,count:data.count});
});
【问题讨论】:
-
data是一个数组,所以data.length可以工作