I
I
ikerya2019-05-22 10:18:52
MongoDB
ikerya, 2019-05-22 10:18:52

Why should we use schema.path when adding a unique index?

Why do we have to add a second line if the index was declared on the first line?

var schema = new Schema({ name: { type: String, unique: true }});
>> schema.path('name').index({ unique: true });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question