add Model.countBy method to count rows in the table by conditions