Friday, 28 April 2017

Mongo / Mongoose: Does Mongoose automatically create indexes on ObjectId types?

I may have missed this in the mongo index documentation or in the mongoose documentation.

Suppose I have a mongoose schema as such:

const SomeEntity = new Schema({
  foo:  { type: String, required: true },
  bar   { type: Schema.ObjectId, ref: 'Bar' }
});

Should I be creating an index on field bar or would mongo automatically address this?

In other words, does mongo automatically create indexes for ObjectId types ?



via dipole_moment

No comments:

Post a Comment