如何查询用户“52ecdb4ea6b03a94179612de”的所有文件,排除最新文件(带有“文章”:“aa”,“已创建”的文件:ISODate(“2014-02-01T13:03:47.577Z”) )?
{
"article":"aa",
"user": ObjectId("52ecdb4ea6b03a94179612de"),
"comment": "222222222",
"created": ISODate("2014-02-01T13:03:47.577Z"),
},
{
"article": "bb",
"user": ObjectId("52ecdb4ea6b03a94179612de"),
"comment": "222222222",
"created": ISODate("2014-01-01T13:03:47.577Z"),
},
{
"article": "cc",
"user": ObjectId("52ecdb4ea6b03a94179612de"),
"comment": "222222222",
"created": ISODate("2013-01-01T13:03:47.577Z"),
}
答案 0 :(得分:0)
您可以按user
进行过滤,按created
降序排序,然后跳过第一个文档:
MyModel.find({user: '52ecdb4ea6b03a94179612de'}).sort('-created').skip(1)
.exec(function(err, docs) { ... });