node.js - 这是express下用mongolass创建一个数据库模型的代码,最后一句代码如何理解?
阿神
阿神 2017-04-17 16:04:27
0
1
468

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

阿神
阿神

闭关修行中......

répondre à tous(1)
伊谢尔伦

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

上述代码是在创建复合索引(author 升序 , _id 降序)

供参考。

Love MongoDB! Have Fun!

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!