计算包含某些内容的mongo集合文档

时间:2015-01-13 20:59:51

标签: mongodb meteor mongodb-query

我有一个集合transfers,其中包含带有一些变量的文档。其中一个是invoice对象。我想知道是否有办法只计算包含该对象的转移(每次转移都不同)。

我的mongo技能不是最好的所以我正在寻找类似的东西:

db.transfers.find(transfer that includes an invoice).count();

这样的东西

示例文件:

{
    "_id" : "JckhdNY8DD72TfRyb",
    "userId" : "T59MQY6gWDCSWS8eq",
    "date" : "Wed Jan 07 2015 15:39:25 GMT-0500 (EST)",
    "files" : [ 
        {
            "url" : "https://www.filepicker.io/api/file/qNpGmyDsT5CLuTxNJkPD",
            "filename" : "Assets.zip",
            "size" : "48 KB"
        }
    ],
    "senderEmail" : "email@gmail.com",
    "recipientEmail" : "email@email.com",
    "invoice" : {
        "total" : "120",
        "tax" : "12",
        "grandTotal" : "134.40",
        "due" : "Upon receipt",
        "stripe" : {
            "id" : "some_id",
            "accessToken" : "some-token",
            "key" : "some-key"
        }
    }
}

0 个答案:

没有答案