我有一个集合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"
}
}
}