K
K
KnightForce2017-02-01 19:04:05
Node.js
KnightForce, 2017-02-01 19:04:05

How in Mongoose to track the uniqueness of the field when adding (I have two options)?

The document has two unique fields.
You can catch this moment using autoIndex: true.
But in production it is recommended to turn it off.
I have two options:
1) Leave.
2) Do find, if there is a match - do not save. Cons - two extra calls to the database (two finds for two fields).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question