You can define a unique compound index using an index
call on your schema:
person.index({ firstName: 1, lastName: 1}, { unique: true });
More Related Contents:
- How do I limit the number of returned items?
- Why Mongoose doesn’t validate on update?
- Mongoose.js: remove collection or DB
- How to sort a populated document in find request?
- Mongoose __v property – hide?
- Updating a Nested Array with MongoDB
- Querying after populate in Mongoose
- Cascade style delete in Mongoose
- Failed to load c++ bson extension
- Comparing mongoose _id and strings
- Find MongoDB records where array field is not empty
- Referencing another schema in Mongoose
- Creating Multifield Indexes in Mongoose / MongoDB
- Mongoose Unique values in nested array of objects
- UnhandledPromiseRejectionWarning: MongooseServerSelectionError
- How to protect the password field in Mongoose/MongoDB so it won’t return in a query when I populate collections?
- Mongoose, find, return specific properties
- How to use mongoose findOne
- MongoDB – Query on the last element of an array?
- Mongoose: Find, modify, save
- Mongoose stopped accepting callbacks for some of its functions
- Mongodb sort with case insensitive manner
- Mongoose: deep population (populate a populated field)
- Mongoose: multiple query populate in a single call
- getting schema attributes from Mongoose Model
- Fail to connect Mongoose to Atlas
- Mongoose overwrite the document rather that `$set` fields
- MongoDB count() versus countDocuments()
- Group by Date with Local Time Zone in MongoDB
- Create unique autoincrement field with mongoose [duplicate]