Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for create_user_item (0.12 sec)

  1. docs_src/sql_databases_peewee/sql_app/crud.py

        db_user.save()
        return db_user
    
    
    def get_items(skip: int = 0, limit: int = 100):
        return list(models.Item.select().offset(skip).limit(limit))
    
    
    def create_user_item(item: schemas.ItemCreate, user_id: int):
        db_item = models.Item(**item.dict(), owner_id=user_id)
        db_item.save()
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 843 bytes
    - Viewed (0)
  2. docs_src/sql_databases_peewee/sql_app/main.py

    
    @app.post(
        "/users/{user_id}/items/",
        response_model=schemas.Item,
        dependencies=[Depends(get_db)],
    )
    def create_item_for_user(user_id: int, item: schemas.ItemCreate):
        return crud.create_user_item(item=item, user_id=user_id)
    
    
    @app.get("/items/", response_model=List[schemas.Item], dependencies=[Depends(get_db)])
    def read_items(skip: int = 0, limit: int = 100):
        items = crud.get_items(skip=skip, limit=limit)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 2.2K bytes
    - Viewed (0)
Back to top