php - Return nested keys in mongodb -
i'm tying nested keys mongodb record structured :
{ "_id" : objectid("ju5ts0m3h4shf0r3x4mpl3"), "statuses" : { "f1r5t1d1n33dt0f1nd" : { "ko status" : [...], "ok status" : [...] }, "s3c0nd1d1n33dt0f1nd" : { "ko status" : [...], "ok status" : [...] }, "th1rd1d1n33dt0f1nd" : { "ko status" : [...], "ok status" : [...] } } the output expect :
[ "f1r5t1d1n33dt0f1nd", "s3c0nd1d1n33dt0f1nd", "th1rd1d1n33dt0f1nd", ] i need ids only, because under "ok status" , "ko status" large amounts of data, impact performance.
i searched through mongo doc , so, found nothing.
how query php mongoclient and/or plain mongodb queries ? it possible ?
try use array_keys() like,
$status = array_keys($obj['statuses']);
Comments
Post a Comment