Mongoose object in a sub array object not being set in Mongoose 6.0.13 #11011
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Illustrating the issue through an example, say we have the following schemas:
If you push an object to the
payments
array, where the object contains a terminal model object, the terminal field gets chopped. For example:transaction.payments[0].terminal
does not exist.The
transaction
object looks like this:If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Using Mongoose
5.13.3
, under the same scenario above,transaction.payments[0].terminal
exists.The
transaction
object looks like this:This behaviour was useful because we could store a snapshot of a model in a different collection and pick the fields we wanted using the Schema definition. In this example we don't want to snapshot the sensitive
apiKey
field.Is there a way to keep this behaviour in Mongoose
6.0.13
?What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node 16.3.0
Mongoose 6.0.13
MongoDB 4.2.17
The text was updated successfully, but these errors were encountered: