node.js中删除mongodb数组子文档元素?

2025-04-05 21:56:03
推荐回答(1个)
回答1:

node.js中删除monogodb数组子文档使用$pull关键词
参考代码:
var filter = {_id: suggestID};
var update = {$pull: {replies: {rid:opts.doc.rid}}};
return opts.dbs.csdb.collection("suggests").findOneAndUpdateAsync(filter, update, {upsert: false})