Houston, we have a problem.
I'm developing a API Rest using mongoose and i need the mongoose don't save POST request's when the unique field value is in there.
Example:
{'_id': '1234', 'fieldUnique': 'fieldTeste'} // Allowed.
{'_id': '1234', 'fieldUnique': 'fieldTeste1'} // Allowed.
{'_id': '5678', 'fieldUnique': 'fieldTeste'} // Allowed.
{'_id': '5678', 'fieldUnique': 'fieldTeste1'}// Allowed.
// Imagine mongoose printing: Are you crazy? This exists.
{'_id': '1234', 'fieldUnique': 'fieldTeste'}
//Imagine Again: I will not repeate. This exists! Get out here.
{'_id':'1234', 'fieldUnique':'fieldTeste1'}
Houston. Can you help me with this little problem showing how to make it in mongoose schema or showing the logic in the request?
From Brazil, with love. Hugo.