I am trying to find a X user whose delimiter is equal to Y. That works find and I can retrieve the document.
Now... Inside that document I've an `Event field` of type `array` that contain other objects.
The user will request only the items of the array from their last timeStamp fetch. so I want just the ones whose `ts` is greater than `XX`
My current query always returns all the results. Is there a way to limit the returned results to the ones that are greater than `XX`??
I am not sure thats possible in mongo, but maybe there is a way?
**Query**
public function testFindInarray() {
$db = $this->db()->socialWall;
$where = array( 'userId' => new MongoId("525c6be048fde2112e8b4626"),
'delimeter' => 21013,
'event' => array('$elemMatch' => array('ts' => array( '$gt' => new MongoDate(1381924477) ) ) )
);
return $db->find( $where );
}
**Result dump**
Array
(
[_id] => MongoId Object
(
[$id] => 525e7dd3f51e9e2d5e127b05
)
[delimeter] => 21013
[event] => Array
(
[0] => Array
(
[_id] => MongoId Object
(
[$id] => 525e7de348fde2132e8b45f4
)
[userId] => MongoId Object
(
[$id] => 525c6be048fde2112e8b4626
)
[verb] => addedRoutine
[ts] => MongoDate Object
(
[sec] => 1381924323
[usec] => 757000
)
[details] => Array
(
[resourceID] => MongoId Object
(
[$id] => 525e7de348fde2132e8b45f3
)
[resourceName] => testr
[authorName] => todk
[exerciseType] => Array
(
[0] => chest
)
)
[likedBy] => Array
(
)
[comments] => Array
(
)
)
[1] => Array
(