jquery - How do i use the mongo query and traverse the mongo(JSON)document and fetch the element by key -
how use mongo query , traverse multiple array , fetch value of key. here json
{ "_id" : "t5zcjquysxcshodjg", "original" : { "name" : "images (1).jpg", "updatedat" : isodate("2015-03-18t11:48:33.124z"), "size" : 10881, "type" : "image/jpeg" }, "uploadedat" : isodate("2015-08-16t13:13:35.392z"), "copies" : { "uploads" : { "name" : "images (1).jpg", "type" : "image/jpeg", "size" : 10881, "key" : "uploads-t5zcjquysxcshodjg-images (1).jpg", "updatedat" : isodate("2015-08-16t13:13:35z"), "createdat" : isodate("2015-08-16t13:13:35z") } }
i want fetch value of size. example can fetch value of uploadedat below
db.cfs.uploads.filerecord.find({},{uploadedat:1}).pretty()
like vise have value of size how query should ?
the query can whatever want return document. {}
, example. can use projection second parameter of find()
method, limit amount of data returned.
when have valid doc
object, can use doc.original.size
access property want.
in mongo shell:
var cursor = db.cfs.uploads.filerecord.find({}, { "original.size": 1}) var doc = cursor.next() // { "_id" : "t5zcjquysxcshodjg", "original" : { "size" : 10881 } } var size = doc.original.size // 10881
Comments
Post a Comment