I am retrieving a DocumentSet in Lithium from MongoDB, but I don't want to process the documents all at once. Instead I would like to have a filter, which I just could tell something like this:
$manyDocuments->giveMeTheOneWhere(array('foo' => 'bar'));
I already tried to do it this way, but it didn't work:
$manyDocuments->find(function($singleDocument){
return ($singleDocument->foo == 'bar');
});
Even if I manually return true inside the closure, it always returns an empty DocumentSet.
Just to add clarity: I am not looking for a database-operation, instead I want to get one out of an already existent DocumentSet. Is there a fancy way to achieve this or do I need to iterate through the set using a custom function?
Instead of using find()
I just used first()
with a closure. This works as expected. Sadly that was the only thing I didn't try before. Excuse me for answering my own question.
Anyway I'd still be interested in a way to get another Document Set.