我想限制一个查询,并在mongoose中获取它的总长度
就像这样:
comment: [1,2,3,4,5,6,7,8,9,10] //length 10
const comments = await CommentModel.find().limit(3).count() //this does not work;
console.log(comments)
output:
{ length: 10, comments: [1, 2, 3] }
多谢了。
我想限制一个查询,并在mongoose中获取它的总长度
就像这样:
comment: [1,2,3,4,5,6,7,8,9,10] //length 10
const comments = await CommentModel.find().limit(3).count() //this does not work;
console.log(comments)
output:
{ length: 10, comments: [1, 2, 3] }
多谢了。
1条答案
按热度按时间ve7v8dk21#
你可以这样使用项目对象进入查询:
示例here,其中输出为: