I use the following document outline:
//User Document { "_id": "0610457c-b25b-4e73-b859-11987a3fe271", "FirstName": "Some Name", "LastName": "surname", // it is array of ledger items "LedgerBook": [ { "AccountId": "aadfgdf6319d3-1a12-4575-9776-c6653sdfg5c32527", "TransactionId": "ef98bbc4-3efb-46dc-b632-5adfgdfg1fcc378446", .... }, ... ]
and when I try to apply the query db.users.find({ "LedgerBook" : { "$type" : 4 } }).limit(50);
, it returns nothing, but for the request db.users.find({ "LedgerBook" : { "$type" : 3 } }).limit(50);
works well (return all documents that have LedgerBook items).
Why is this happening?
type = 4 is Array, and type = 3 is Object.
I want all documents to have at least one LedgerBook item.
source share