gpt4 book ai didi

json - MongoDB find()。count()-SyntaxError : missing : after property id (shell):1

转载 作者:行者123 更新时间:2023-12-03 08:14:43 24 4
gpt4 key购买 nike

有一个.json数据提供的推文集合。

希望计算 session 中的删除请求:

db.tweets.find({"delete"}).count()

而且这种语法是不正确的,因为 SyntaxError: missing : after property id (shell):1
有更多的 find()count()操作要执行,但是错误是一致的。

这是Delete-Request的样子(其中 是一系列字母和/或数字):
{
"_id" : ObjectId("…"),
"delete" : {
"status" : {
"id" : NumberLong("…"),
"user_id" : …,
"id_str" : "…",
"user_id_str" : "…"
}
}
}

最佳答案

find()函数中,您必须传递一个对象。您错过了键/值,因为{"delete"}不是有效的对象。

我认为您想获取具有删除键的文档数。为此,您必须将$exists运算符与true值一起使用。

db.tweets.find({ "delete": { $exists: true } }).count();

或直接
db.tweets.count({ "delete": { $exists: true } });

documentation:

$exists selects the documents that contain the field if is true. If is false, the query only returns the documents that do not contain the field. Documents that contain the field but has the value null are not returned.

关于json - MongoDB find()。count()-SyntaxError : missing : after property id (shell):1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16637636/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com