0
我正在通过一个使用猫鼬来填充MongoDB的例子。Mongoose:schema.index在几行
var eventSchema = new mongoose.Schema({
_id: { type: String },
name: { type: String, required: true},
description: {type: String},
venue: {type: String}, });
eventSchema.plugin(require('./plugins/pagedFind'));
eventSchema.index({ name: 1 });
eventSchema.index({ date: 1 });
eventSchema.index({ venue: 1 });
我不知道schema.index是什么;所以我查了一下; http://mongoosejs.com/docs/guide.html;我所学到的是,除了默认的_id排序之外,它是一种排序集合的方法。
但是我写的内容和以下内容有什么区别吗?
eventSchema.index({ name: 1, date: 1,venue: 1 });
[猫鼬中/ MongoDB的创建索引万事]的可能的复制(https://stackoverflow.com/questions/ 12573753 /创建multifield-indexes-in-mongoose-mongodb) –
我知道,我想知道两种方式之间的区别 – pivu0