I have a collection of offers and complicated query with a lot of fields and sorting. The task is to find a previous and next documents in the query results having only a query array and current document ID. So I'm writing a javascript function that performs a query with sorting and returns two IDs. The problem is to convert php query array into a correct javascript object.
Something like this, for example:
$query = array('city' => new MongoId('...'), 'price' => array('$gt' => 100000), ...);
$sort = array('price' => -1);
$code = new MongoCode("function findPrevNext() { db.offer.find($query).sort($sort).forEach(function(obj){ ... }) }");
How can I make such conversion?