Exemple #1
0
def update_keyword(
        *,
        _: bool = Depends(is_authenticated),
        repository: KeywordRepository = Depends(get_keyword_repository),
        id: int,
        keyword_update: KeywordUpdate):
    db_keyword: DBKeyword = or_404(repository.get(id))
    updated: DBKeyword = repository.update(
        db_keyword, keyword_update.dict(skip_defaults=True))
    return updated
Exemple #2
0
def update_keyword(
    *,
    _: bool = Depends(is_authenticated),
    repository: KeywordRepository = Depends(get_keyword_repository),
    id: int,
    keyword_update: KeywordUpdate,
):
    db_keyword: DBKeyword = or_404(repository.get(id))
    updated: DBKeyword = repository.update(
        db_keyword, keyword_update.dict(exclude_unset=True))
    return updated.to_model()
Exemple #3
0
def get_keyword(
        *,
        repository: KeywordRepository = Depends(get_keyword_repository),
        id: int):
    keyword: Optional[DBKeyword] = repository.get(id)
    return or_404(keyword)