A problem occurs: The_idfield of data 2 is in thefriendsfield of data 1. At this time, I want to delete data 2, but thefriendsfield The_idfield is not deleted.
Question: After deleting data 2, all_idrelated to field 2 will be automatically deleted.
If it cannot be deleted automatically, does it mean that I have to re-query and then delete it? ?
I searched around on Baidu but couldn’t find the answer. Maybe I didn’t catch the keyword. . So I came here to ask. . Daniel, please help me.

Yes, unlike
relational database, inMongoDByou need to query and delete it yourself. Maybe in order to delete it quickly, you may also need to reversely record the relationship.MongoDB does not have cascading deletes. When an application needs to delete data, the application itself is responsible for removing any references related to the deleted data.