-
New to mongodb and mongoid and I basically copied an example from the docs (https://www.mongodb.com/docs/mongoid/current/reference/associations/#dependent-behavior). Code shown below. However, when I delete a Band record the associated Album records do no seem to be deleted (which I verify in mongosh after executing the program) and instead appear to be orphaned. Can someone please explain what I am not understanding? Thanks much!
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Sorry, I just realized this should be in the 'Q&A' category. |
Beta Was this translation helpful? Give feedback.
-
Hi @joep, The Thank you for pointing this out, I understand that the naming of the option and the documentation of the |
Beta Was this translation helpful? Give feedback.
Hi @joep,
The
delete
method only deletes the document itself. No callbacks are triggered, no associations are deleted. Contrary, thedestroy
method does what is expected. If you callBand.first.destroy
, the albums will be deleted.Thank you for pointing this out, I understand that the naming of the option and the documentation of the
delete
method can be improved.