![](/img/trans.png)
[英]JSON to JS with Django: SyntaxError: missing : after property id
[英]MongoDB find().count() - SyntaxError: missing : after property id (shell):1
有一個.json數據提供的推文集合。
希望計算會話中的刪除請求:
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"}
不是有效的對象。
我認為您想獲取具有刪除鍵的文檔數。 為此,您必須使用具有true
值的$exists
運算符。
db.tweets.find({ "delete": { $exists: true } }).count();
或直接
db.tweets.count({ "delete": { $exists: true } });
從文檔 :
如果為true,則$ exists選擇包含該字段的文檔。 如果為false,則查詢僅返回不包含該字段的文檔。 不返回包含該字段但值為null的文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.