Login
Basic migrations with alembic
Get items
This commit is contained in:
2023-02-19 02:47:14 +00:00
parent c807fbcf03
commit 6700a4e2ef
25 changed files with 616 additions and 9 deletions

16
crud/items.py Normal file
View File

@@ -0,0 +1,16 @@
from sqlalchemy.orm import Session
from models.items import Item
from schemas.items import ItemCreate
def get_items(db: Session, skip: int = 0, limit: int = 100):
return db.query(Item).offset(skip).limit(limit).all()
def create_user_item(db: Session, item: ItemCreate, user_id: str):
db_item = Item(**item.dict(), owner_id=user_id)
db.add(db_item)
db.commit()
db.refresh(db_item)
return db_item