12345678910111213141516171819202122232425262728293031323334 |
- from typing import Any, Dict, List, Optional, Union
- from sqlalchemy.orm import Session
- from app.core.security import get_password_hash, verify_password
- from app.crud.base import CRUDBase
- from app.models.nft import nft
- from app.schemas.nft import NftBase, NftCreate, NftUpdate
- class CRUDUser(CRUDBase[nft, NftBase, NftCreate]):
- def get_multi_by_owner(
- self, db: Session, *, skip: int = 0, limit: int = 100, owner_id: str
- ) -> List[nft]:
- return db.query(nft).filter(nft.userid==owner_id).offset(skip).limit(limit).all()
- def create_with_owner(self, db: Session, *, obj_in: NftCreate, owner_id:str) -> nft:
- db_obj = nft(
- hash=obj_in.hash,
- imgurl=obj_in.imgurl,
- userid=owner_id,
- title=obj_in.title,
- context=obj_in.context,
- is_active=obj_in.is_active,
- category=obj_in.category
- )
- db.add(db_obj)
- db.commit()
- db.refresh(db_obj)
- return db_obj
- nft = CRUDUser(nft)
|