search

Home  >  Q&A  >  body text

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 days ago520

reply all(1)I'll reply

  • 伊谢尔伦

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

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

    The above code is creating a composite index (author ascending order, _id descending order)

    For reference.

    Love MongoDB! Have Fun!

    reply
    0
  • Cancelreply