support __after_id and __before_id

close #306