repository: query interface refactoring, added query builder & count query