You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for both the model path and the _id path
When I delete the EquipmentSchema.plugin(uniqueValidator); the model gets saved correctly again.
What's weird is that mongoose-unique-validator works like a charm for my user validation...
@mousto090 seem to have found the origin of the problem. I'm calling one of my model field: model which seems to confuse your code in this section .
You can read his answer to my question on SO there.
I just ran into this, and was causing me a headache but I think I have a fix, which is to add an else to get the model from the constructor as the default case
let model;
if (isQuery) {
model = this.model;
} else if (isSubdocument) {
model = this.ownerDocument().model(this.ownerDocument().constructor.modelName);
} else if (isFunc(this.model)) {
model = this.model(this.constructor.modelName);
==> } else {
==> model = this.constructor.model(this.constructor.modelName);
==> }
Hey!
I'm not sure it's reasonable to post this here but I got a weird error for which I can't seem to find any solution:
Here's my model:
but when I try to save a new equipment:
I get the following error:
for both the
model
path and the_id
pathWhen I delete the
EquipmentSchema.plugin(uniqueValidator);
the model gets saved correctly again.What's weird is that
mongoose-unique-validator
works like a charm for my user validation...I've created a question on SO about this here: https://stackoverflow.com/questions/61802039/mongoose-cannot-read-property-where-of-undefined-id
The text was updated successfully, but these errors were encountered: