mirror of
https://github.com/OnyxALeroy/Cephalon-Onni.git
synced 2026-09-10 17:37:47 +02:00
17 lines
556 B
Python
17 lines
556 B
Python
from typing import List, Optional
|
|
|
|
from bson import ObjectId
|
|
from database.db import db_manager
|
|
|
|
|
|
class InventoryRepository:
|
|
@staticmethod
|
|
async def find_by_user(user_id: str) -> List[dict]:
|
|
cursor = db_manager.inventories.find({"user_id": ObjectId(user_id)})
|
|
return [item async for item in cursor]
|
|
|
|
@staticmethod
|
|
async def find_by_id_and_user(item_id: str, user_id: str) -> Optional[dict]:
|
|
return await db_manager.inventories.find_one(
|
|
{"_id": ObjectId(item_id), "user_id": ObjectId(user_id)}
|
|
)
|