Mongoose attempting to cast subdocument schema to string #11506
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Do you want to request a feature or report a bug?
I think a bug, but may just be confused.
What is the current behavior?
I have the following schema with a subdocument:
I am trying to PATCH the following data via my API on a model created via the above schema:
Using the following JavaScript code:
But, I get the error
Error: Validation failed: awards: Cast to embedded failed for value "..." (type string)
from theProfile.validate()
step:If the current behavior is a bug, please provide the steps to reproduce.
Please see above.
What is the expected behavior?
I would not expect this data to fail validation. I've also tried creating a
new Date()
fromawards[0].date
but the same error occurred.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node
node --version
:v14.14.0
Mongoose
node -e 'console.log(require("mongoose").version)'
:6.2.4
MongoDB
v4.4
on DigitalOceanThe text was updated successfully, but these errors were encountered: