因此,当我运行此查询删除一些好友请求文档时:
db.friendRequests.deleteMany([
{
$and: [
{ author: ObjectId("636a88de3e45346191cf4257") },
{ friend_id: ObjectId("636faabb1861c5b8773f751e") },
],
},
]);
然后它不删除任何东西,我不知道为什么。
以下是从MongoDB Compass导出为JSON的friendRequests文档:
[{
"_id": {
"$oid": "63764d512bf0d70cbce32664"
},
"author": {
"$oid": "636fa1ce289c56d125ac8a4a"
},
"friend_id": {
"$oid": "636a88de3e45346191cf4257"
},
"request_at": {
"$date": {
"$numberLong": "1668697425541"
}
},
"__v": 0
},{
"_id": {
"$oid": "63764d622bf0d70cbce32673"
},
"author": {
"$oid": "636cf37d8a8b51a38932d3d8"
},
"friend_id": {
"$oid": "636a88de3e45346191cf4257"
},
"request_at": {
"$date": {
"$numberLong": "1668697442809"
}
},
"__v": 0
},{
"_id": {
"$oid": "637cc8e760709f87c46ad5a9"
},
"author": {
"$oid": "636a88de3e45346191cf4257"
},
"friend_id": {
"$oid": "636faabb1861c5b8773f751e"
},
"request_at": {
"$date": {
"$numberLong": "1669122279674"
}
},
"__v": 0
}]
你能告诉我为什么它不删除任何东西吗?谢谢!
1条答案
按热度按时间ev7lccsx1#
我想出来了
我只需要在deleteMany查询之后放置一个
.exec()