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 add_backend(self, backend):
        """
        Adds a new backend to the list

        @param backend_id: the id of the backend to add
        """
        if backend:
            backend_iter = self.liststore.append([
                backend.get_id(),
                self.dialog.get_pixbuf_from_icon_name(backend.get_icon(),
                                                      16),
                backend.get_human_name(),
                self._get_markup_for_tags(backend.get_attached_tags()),
            ])
            self.backendid_to_iter[backend.get_id()] = backend_iter