src/main.py
async def update_note(note_id: int, payload: NoteIn):
    """Update one note given its id"""
    query = notes.select().where(notes.c.id == note_id)
    row = await database.fetch_one(query=query)
    if row is None:
        logger.info("No record !")
        raise HTTPException(
            status_code=404,
            detail="Item not found",
            headers={"X-Error": f"Request asked for note id: [{note_id}]"}
        )
    query = notes.update().where(notes.c.id == note_id).values(text=payload.text, completed=payload.completed)
    await database.execute(query=query)
    return {**payload.dict(), "id": note_id}
Update one note given its id
Update one note given its id
Update one note given its id
async def update_note(note_id: int, payload: NoteIn):
    query = notes.select().where(notes.c.id == note_id)
    row = await database.fetch_one(query=query)
    if row is None:
        logger.info("No record !")
        raise HTTPException(
            status_code=404,
            detail="Item not found",
            headers={"X-Error": f"Request asked for note id: [{note_id}]"}
        )
    query = notes.update().where(notes.c.id == note_id).values(text=payload.text, completed=payload.completed)
    await database.execute(query=query)
    return {**payload.dict(), "id": note_id}
async def update_note ( note_id : int , payload : NoteIn ) : query = notes . select ( ) . where ( notes . c . id == note_id ) row = await database . fetch_one ( query = query ) if row is None : logger . info ( "No record !" ) raise HTTPException ( status_code = 404 , detail = "Item not found" , headers = { "X-Error" : f"Request asked for note id: [{note_id}]" } ) query = notes . update ( ) . where ( notes . c . id == note_id ) . values ( text = payload . text , completed = payload . completed ) await database . execute ( query = query ) return { ** payload . dict ( ) , "id" : note_id }
Update one note given its id
Update one note given its id
"""Update one note given its id"""
note_id
int
payload
NoteIn