最近我在自学MongoDB和Python,遇到了这个问题。
https://i.stack.imgur.com/acQxl.png

对于object 1-3,其中有date信息,但有些对象不包含日期。如何使用MongoDB和Python脚本移除其中的object that doesn't contain date?提前谢谢。
发布于 2021-01-31 19:43:02
试试看
update(
{} ,
{ "$pull": { data :{ date: { "$exists": false } }} },
false,true)发布于 2021-01-31 19:11:13
使用$pull从数组中删除项。
Find part of update:使用$exists on date字段检查是否存在。
db.coll.update({},
{
"$pull": {
"arr": {
"a": {
exists: false
}
}
}
})https://stackoverflow.com/questions/65978395
复制相似问题