feat: allow delete merchant from nostr
This commit is contained in:
parent
260bea9ccf
commit
05ecc65e5a
7 changed files with 141 additions and 11 deletions
14
crud.py
14
crud.py
|
|
@ -7,6 +7,7 @@ from . import db
|
|||
from .models import (
|
||||
DirectMessage,
|
||||
Merchant,
|
||||
MerchantConfig,
|
||||
Order,
|
||||
PartialDirectMessage,
|
||||
PartialMerchant,
|
||||
|
|
@ -35,6 +36,19 @@ async def create_merchant(user_id: str, m: PartialMerchant) -> Merchant:
|
|||
return merchant
|
||||
|
||||
|
||||
async def update_merchant(
|
||||
user_id: str, merchant_id: str, config: MerchantConfig
|
||||
) -> Optional[Merchant]:
|
||||
await db.execute(
|
||||
f"""
|
||||
UPDATE nostrmarket.merchants SET meta = ?
|
||||
WHERE id = ? AND user_id = ?
|
||||
""",
|
||||
(json.dumps(config.dict()), merchant_id, user_id),
|
||||
)
|
||||
return await get_merchant(user_id, merchant_id)
|
||||
|
||||
|
||||
async def get_merchant(user_id: str, merchant_id: str) -> Optional[Merchant]:
|
||||
row = await db.fetchone(
|
||||
"""SELECT * FROM nostrmarket.merchants WHERE user_id = ? AND id = ?""",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue