class MongoDbCategoryRepository implements CategoryRepository {

    @Override
    public int removeFromCreatedOrModifiedFields(String userId) {
        List<MongoDbCategory> categories = template.find(query(where("lastModifiedUserId").is(userId).orOperator(where("createdUserId").is(userId))), CLASS, CATEGORY_COLLECTION);
        int count = 0;
        for(MongoDbCategory category : categories) {
            boolean updated = updateCategory(userId, category);
            if(updated) {
                save(category);
                count++;
            }
        }
        return count;
    }

}