Say I have two models, a Team
and a Player
, the Player
has an ObjectId field that stores a Team
's id. If I were to delete a Team
, would all the Player
s storing the object Id field become null, or would I manually have to make it null.
Asked
Active
Viewed 202 times
0

marc2019
- 47
- 5
-
You'd need to manually make them null. There's no concept of foreign keys in mongo. – R J Feb 24 '21 at 20:24
-
1mongoose does support cascade delete, but native mongodb does not. Check out this post: https://stackoverflow.com/questions/14348516/cascade-style-delete-in-mongoose – codemonkey Feb 24 '21 at 20:39