0

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 Players storing the object Id field become null, or would I manually have to make it null.

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
  • 1
    mongoose 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

0 Answers0