mirror of
https://github.com/RYDE-WORK/full-stack-fastapi-template.git
synced 2026-01-21 14:19:06 +08:00
🐛 Fixed items count when retrieving data for all items by user (#695)
This commit is contained in:
parent
5373286d8a
commit
98c78e4683
@ -17,13 +17,18 @@ def read_items(
|
||||
Retrieve items.
|
||||
"""
|
||||
|
||||
statment = select(func.count()).select_from(Item)
|
||||
count = session.exec(statment).one()
|
||||
|
||||
if current_user.is_superuser:
|
||||
statment = select(func.count()).select_from(Item)
|
||||
count = session.exec(statment).one()
|
||||
statement = select(Item).offset(skip).limit(limit)
|
||||
items = session.exec(statement).all()
|
||||
else:
|
||||
statment = (
|
||||
select(func.count())
|
||||
.select_from(Item)
|
||||
.where(Item.owner_id == current_user.id)
|
||||
)
|
||||
count = session.exec(statment).one()
|
||||
statement = (
|
||||
select(Item)
|
||||
.where(Item.owner_id == current_user.id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user