我有一些具有以下结构的 mongoDB 文档:
[_id] => MongoId Object (
[$id] => 50664339b3e7a7cf1c000001
)
[uid] => 1
[name] => Alice
[words] => 1
[formatIds] => Array (
[0] => 1
[1] => 4
)
我想要做的是找到 formatIds[] 中值为 1 的所有文档。我认为有可能做到这一点。我怎样才能在 PHP 中做到这一点?
更新
谢谢您的帮助。它现在工作正常。这是我编写搜索的方式,
$id=$_POST['id'];
$query = array('formatIds'=> "{$id}" );
$result = $stations_table->find($query); //where $stations_table = $db->stations;