var comment = new Schema({
text: {type:String}
});
var Post = new Schema({
comments : [comment]
});
我有一个帖子对象的“n”条记录,我想根据限制和跳过检索评论数据。
我想在从帖子模型填充评论数据时为评论架构添加分页。
实现方法是什么?
最佳答案
您可以使用$slice .
db.posts.find( {}, { comments: { $slice: [ 20, 10 ] } } )
关于node.js - 在 mongoose 子文档中设置跳过和限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48076376/