def get(self, id, pk='id', deleted=False):
        try:
            if pk == 'id':
                id = int(id)
            if deleted:
                spec = {pk: id}
            else:
                spec = {pk: id, 'data': {'$exists': 1}}
            fields = {'_id': 0}
            row = self.db.docs.find_one(spec, fields)
        except Exception as e:
            raise DatabaseException(e)
        if row:
            return Document(**row)
        raise NotFoundError('%s %s not found' % (pk, id))
def _swdb_group_upgrade(self, group_id, pkg_types, pkgs):
        if not self._base.history.group.get(group_id):
            self._raise_or_warn( self._ignore_installed, _("Group id '%s' is not installed.") % group_id)
            return

        swdb_group = self._create_swdb_group(group_id, pkg_types, pkgs)

        if swdb_group is not None:
            self._base.history.group.upgrade(swdb_group)