fix before_id and after_id behaviour with mongodb