Implementing Unique Fields

You can specify that the value of a field must be unique in a collection, meaning that no other documents can have the same value for that field. You do this by adding the unique property to the Schema object definition. For example, to add an index and make the name field unique in the collection, you use:

var schema = new Schema({
  name: {type: String, index: 1, unique: true}
};

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.239.105