Add database object *_count() function and tests.