0

I am working on a project in Symfony2.2 and MongoDB.

Currently I can retrieve all the Objects from my Database and traverse them to get the desired object.

$dm = $this->get('doctrine_mongodb')->getManager();
$users = $dm->getRepository('Database:User')->findAll();

And then loop them in order to get the next and previous object.

I was wondering if there was a easier and efficient way to find the next and previous object in ODM?

Thanks.

Shrujan Shetty
  • 2,298
  • 3
  • 27
  • 44
  • If you only have a single document, then to find the next or previous: you'll need to either have an index to sort on (and do a range query), or pointers to the previous/next documents. – WiredPrairie Jul 10 '13 at 13:42
  • possible duplicate of [MongoDB query for related records](http://stackoverflow.com/questions/14550035/mongodb-query-for-related-records) – WiredPrairie Jul 10 '13 at 13:43

0 Answers0