数据长这样——
_id:"123213213"
list:[
{id:"1",flag:false,sublist:["as3d","rew7","t3re","fdd6sf"]},
{id:"2",flag:false,sublist:["as5d","re6w","tr6e","fdd5sf"]},
{id:"3",flag:true,sublist:["as765d","r5ew","tr7e","f3ddsf"]},
{id:"4",flag:true,sublist:["as9d","re2w","tr8e","fd5dsf"]},
{id:"5",flag:true,sublist:["asd","rew","tr9e","f5ddsf"]},
{id:"6",flag:true,sublist:["asd","rew","tr9e","f5ddsf"]},
{id:"7"}
]
我想删除list下id为2的那个对象,只删除这一项。
我本来想的是这个语法
db.collection('xxxx').doc(event._id).update({
data:{
list: _.pull(_.in([{id:"2"}]))
}
})
但这个语句无效,后经查阅,这个语法的意思是,{id:"2"}必须全匹配,意思是如果把{id:"2"}换成{id:"7"}就可以正常删除最后一项。
然后,那个sublist,很长……无法完全匹配。
那么我怎么删除,list下,id为2的这一行呢?
1、没仔细看文档。
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.pull.html
文档的最后两个例子。