Query array element and then field, from MongoDB -


suppose have following document in collection:

{      "_id":objectid("1123562e7c594c12942f"),    "figures":[         {            "shape":"square",          "color":"blue"       },       {            "shape":"triangle",          "color":"black"       }    ] } 

i make query selects field "shape" second element of array "figures".

using db.test.find({}, {"figures": {$slice: [2, 1]}}) can access second element of "figures", can select only field "shape" there?

use below query

db.test.find({}, {"figures": {$slice: [2, 1]}, "figures.shape": 1}).pretty(); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -