I'm new in mongoDB, I saw enough examples but most show how to work with collections.
I have followed data stored in mongoDB under DB name myDB
:
"_id" : "some_table_name",
"content" : [{
"id" : "1",
"loctype" : "Clinic/Hospital",
"locname" : "KKH"
}, {
"id" : "2",
"loctype" : "Clinic/Hospital",
"locname" : "Singapore National Eye Centre"
}
}]
}
As you can see the model contains _id
and content
, where content
is list of objects:
... ,
{
"id" : "ZZZ",
"loctype" : "ZZZ",
"locname" : "ZZZ"
},
...
PHP
$m = new MongoClient(/* ... */);
$db = $m->myDB;
$collection = $db->coll;
How can I fetch in PHP list of ids? a.e [1,2]
in my case.
For sure I can get all model and extract ids but I try to do it stright from mongoDB.
Thanks.