I am using the following Mongoose model:
var Test = db.model('Test', db.Schema({ one: { type: String, required: true }, two: { type: String, required: true } }, { strict: false }) );
It has two required fields: one
and two
and strict:false
, because there may be other fields with undefined names.
I would like the combination of one
and two
be unique. This means that there can be several documents with the same one
or the same two
, but none of them should have the same combination of one
and two
.
Can this be done with Mongoose?
Juicy source share