Skip to content
Advertisement

How to make sure that objects do not have the same two element in mongoose schema?

I am making the following mongoose schema and i want to make sure that no object has the same autherFirstName and autherLastName. object may have one in common but not both of them

JavaScript

Advertisement

Answer

https://mongoosejs.com/docs/2.7.x/docs/indexes.html

Create a composite unique index

JavaScript
Advertisement