0

I have a collection transfers that includes documents with a few variables. One of them is an invoice Object. I am wondering if there is a way to count only transfers that include that Object (it's different for every transfer).

My mongo skills aren't the best so I'm looking for something like:

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

Sample document:

{
    "_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"
        }
    }
}
Disposer
  • 6,201
  • 4
  • 31
  • 38
416serg
  • 348
  • 2
  • 17

0 Answers0