Implement Purchase.count and Category.count, so we can use them in
tests.