Countable implementation for DocumentRepository

Fixes #833