INNER CODE UNIT · Python

get

testdrivenio/fastapi-crud-async · src/app/api/crud.py:10

async def get(id: int):
    query = notes.select().where(id == notes.c.id)
    return await database.fetch_one(query=query)


async def get_all():
    query = notes.select()
    return await database.fetch_all(query=query)


async def put(id: int, payload: NoteSchema):
    query = (
        notes
        .update()
        .where(id == notes.c.id)
        .values(title=payload.title, description=payload.description)
        .returning(notes.c.id)
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…