【发布时间】:2018-11-02 07:29:55
【问题描述】:
酒店表中的数据是这样存储的
{
_id: ....,
HotelName: ...,
MasterKeyDetails:[
{
MasterKeyId: 36K1,
...
},
{
MasterKeyId: 36J1,
...
}
]
}
我在下面写了查询
$cursor = $this->collection->aggregate(array(
array(
'$match' => array(
"_id" => new MongoDB\BSON\ObjectID($this->id)
)
),
array(
'$project' => array(
'MasterKeyDetails' => array(
'$filter' => array(
'input' => '$MasterKeyDetails',
'as' => 'room',
'cond' => array(
'$eq' => array('$$room.MasterKeyId', $this->MasterKeyId)
)
)
),
)
)
)
)->toArray();
搜索正常。 $this->MasterKeyId 包含 36k1 时搜索,但 $this->MasterKeyId 包含 36k1 时不搜索。尽管有区分大小写的数据,但我希望它应该获取...
请帮忙!!!
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework mongodb-php php-mongodb