javascript - Problem with mongose deleting multiple fields at once
为情所困
为情所困 2017-05-17 09:56:52
0
1
516

The code in the controller is as follows:
The parameters received by removeStaff have two fields.ids data type is an array, and the array stores the sid of the field to be deleted

The exposed models are as follows:

Is it possible to use the deletemany method? This method has never been used... Is there any database guy who can give me a try and give me an answer? T——T

为情所困
为情所困

reply all (1)
滿天的星座

You misunderstood the meaning of the deletemany method. When multiple documents have similar data, such as multiple employees with different ages, if you want to delete the data of all employees over 30 years old at one time, useModel.deleteMany({ age: { $gte: 30 } }, function (err) {}), if you can find some commonality in the sid (regular matching will also work), you can use deletemany, but I estimate that this is almost impossible, and deleting multiple times in a loop is inevitable.

    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!