-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
As far as I can tell there is no way to find an object containing a value in a subarray if you do not know the exact array-key path, so if the following were a collection of orders you cannot find all orders by unit ID without modifying the schema:
array(
'_id' => 213,
'units' = array(
0 => array('id' => 5, 'color' => 'red'),
1 => array('id' => 3, 'color' => 'blue'),
2 => array('id' => 8, 'color' => 'polka dot'),
3 => array('id' => 9, 'color' => 'green')
)
);
array(
'_id' => 456,
'units' = array(
0 => array('id' => 8, 'color' => 'purple'),
1 => array('id' => 2, 'color' => 'yellow')
)
);
We should be able to do something like:
$find = array('units.$*.id' => 8);
$col->find($find);
Assuming $* would be a wildcard operator that covers any key within the array
- duplicates
-
SERVER-267 Wildcard support in index/query/projection
- Backlog