class MongoDbPageRepository implements PageRepository {

    @Override
    public List<PageUser> getPagesForUser(String userId, String pageType) {
        List<Page> pages = template.find(query(where("members").elemMatch(where("userId").is(userId)).andOperator(where("pageType").is(getString(pageType)))));
        List<PageUser> userList = Lists.newArrayList();
        for(Page page : pages) {
            userList.add(findPageUser(userId, page));
        }
        return sortUsers(userList, userId);
    }

}