My object is like following.
{ "_id" : ObjectId("4ec3ba6fb8af0adbaf2ffc2a"), "list" : { "list1" : "sample", "list2" : "test2" } }
I want to count total record under “list”. Can I do this in shell ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think there are any queries on the database side for that. You could use simple map/reduce but in your case probably the easiest way is to just fetch the whole document and then count the items with javascript loop like this: