Fix pagination bug with MongoDB query.