Consider the database has the following records,
{id: 1, device: 'A'},
{id: 1, device: 'B'}
Now, If I want to insert {id: 1, device: 'A'}
the record should not be created as id: 1
already exists for device A
.
So, how will the Mongoose schema look?