搜尋

首頁  >  問答  >  主體

node.js - 这是express下用mongolass创建一个数据库模型的代码,最后一句代码如何理解?

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();// 按创建时间降序查看用户的文章列表 这里如何理解?

阿神阿神2875 天前521

全部回覆(1)我來回復

  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:06:27

    exports.Post.index({ author: 1, _id: -1 }).exec();

    上述程式碼是在建立複合索引(author 升序 , _id 降序)

    供參考。

    Love MongoDB! Have Fun!

    回覆
    0
  • 取消回覆