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

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

阿神
阿神

闭关修行中......

Antworte allen(1)
伊谢尔伦

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

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

供参考。

Love MongoDB! Have Fun!

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!