2013-05-19 18 views
0

有鳴叫的以.json數據採集提供..MongoDB中找到()COUNT() - 語法錯誤:。丟失:物業編號(殼)後:1

展望算在會話中刪除,要求:

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

這句法不正確,因爲SyntaxError: missing : after property id (shell):1

有更多find()count()操作來執行,但錯誤是一致的。

這是一個刪除請求看起來像(其中「......」可以是一系列字母和/或數字)

{ 
    "_id" : ObjectId("…"), 
    "delete" : { 
     "status" : { 
      "id" : NumberLong("…"), 
      "user_id" : …, 
      "id_str" : "…", 
      "user_id_str" : "…" 
     } 
    } 
} 

回答

5

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.

+0

完美。乾杯,謝謝.. – sourcingsynergy

相關問題