javascript - mongodb reference cannot delete reference when deleting data
三叔
三叔 2017-07-03 11:41:12
0
1
1380

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.

三叔
三叔

reply all (1)
曾经蜡笔没有小新

Yes, unlikerelational 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 has no cascading deletes. When your application deletes data, it is also responsible for removing any referenced objects itself and any references to the deleted document.

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.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!