mirror of
https://github.com/kevin-DL/fast_api_api_template.git
synced 2026-01-12 10:05:15 +00:00
Register
Login Basic migrations with alembic Get items
This commit is contained in:
16
crud/items.py
Normal file
16
crud/items.py
Normal 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
|
||||
Reference in New Issue
Block a user