Automattic / Automattic/mongoose
Embedded document .save() not persisting
- Dominant language
- JavaScript
- Stars
- 27.5k
- Forks
- 4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 35
Description
See gist: https://gist.github.com/xizhao/6ba5bc02229ba0e8eb48
When I try to save Child it passes with no error and looks like it saved, but it doesn't persist in the db.
I am pushing data to an array in the embedded schema via a method bound to the embedded schema. markModified does not help. Using doc.__parent.save() does work, however.
Contributor guide
Research direction
Start with the reproduction in the linked gist and compare saving the embedded Child with saving its parent via __parent.save(). Trace the embedded schema's save behavior and markModified usage, then add a regression test showing whether array changes persist after Child.save().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, nodejs
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100