{
"_id" : 654321,
"first_name" : "John",
"last_name" : "Doe",
"interested_by" : [ "electronics", "sports", "music" ],
"address" : {
"name" : "John Doe",
"company" : "Resultri",
"street" : "1015 Mapple Street",
"city" : "San Francisco",
"state" : "CA",
"zip_code" : 94105
}
}
How can i find the name of elements in array 'intersted_by' using command??
您可以通过执行以下操作来计算密钥数量:
var count = Object.keys(myObject).length;
You can have the size of your result in the mongo shell using :
db.collection.count()
Replace collection by the name of your collection. You can also add a find condition like this :
db.collection.find().count()
Like that, you wan restrict your result with deffernts clauses before count the numbers of data corresponding
Edit : don't forget to do the command use databaseName
if you're not in your database, it does'nt work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.