Skip to content

Push to document array fails #8312

Closed
Closed
@avichaishapira1

Description

@avichaishapira1

This behavior exists in version 5.7.8
This behavior does not exist in version 5.6.9

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

story is a complex document with many subdocuments and subdocuments arrays
let obj = story.segmentation // this is a subdocument array
let segmentation = {
// json object contains fields according to Segmentation model
}
obj.push(segmentation)

Error output:

Cannot read property ' __$' of undefined\nTypeError: Cannot read property ' __$' of undefined\n at _updateParentPopulated (/Users/avichaishapira/IdeaProjects/bigvu-webserver/node_modules/mongoose/lib/types/documentarray.js:323:14)\n at CoreDocumentArray.push (/Users/avichaishapira/IdeaProjects/bigvu-webserver/node_modules/mongoose/lib/types/documentarray.js:187:5)\n

What is the expected behavior?

array.push is successful

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

Node v12.10.0
Mongoose v5.7.8
MongoDB v3.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions