问题描述
exports.Post = mongolass.model(’Post’, { author: { type: Mongolass.Types.ObjectId }, title: { type: ’string’ }, content: { type: ’string’ }, pv: { type: ’number’ }});exports.Post.index({ author: 1, _id: -1 }).exec();// 按创建时间降序查看用户的文章列表 这里如何理解?
问题解答
回答1:exports.Post.index({ author: 1, _id: -1 }).exec();
上述代码是在创建复合索引(author 升序 , _id 降序)
供参考。
Love MongoDB! Have Fun!