mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-04 10:19:26 +02:00
Extend transaction usage
This commit is contained in:
parent
62f4e368a6
commit
abc2102da5
47 changed files with 1367 additions and 860 deletions
|
@ -96,27 +96,31 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||
throw new BadRequest()
|
||||
}
|
||||
|
||||
const userEntryUnsafe = await database.user.findOne({
|
||||
where: {
|
||||
mail
|
||||
},
|
||||
attributes: ['familyId']
|
||||
})
|
||||
await database.transaction(async (transaction) => {
|
||||
const userEntryUnsafe = await database.user.findOne({
|
||||
where: {
|
||||
mail
|
||||
},
|
||||
attributes: ['familyId'],
|
||||
transaction
|
||||
})
|
||||
|
||||
if (!userEntryUnsafe) {
|
||||
throw new Conflict('no user with specified mail address')
|
||||
}
|
||||
if (!userEntryUnsafe) {
|
||||
throw new Conflict('no user with specified mail address')
|
||||
}
|
||||
|
||||
const userEntry = {
|
||||
familyId: userEntryUnsafe.familyId
|
||||
}
|
||||
const userEntry = {
|
||||
familyId: userEntryUnsafe.familyId
|
||||
}
|
||||
|
||||
await addPurchase({
|
||||
database,
|
||||
familyId: userEntry.familyId,
|
||||
type,
|
||||
transactionId: 'manual-' + type + '-' + generatePurchaseId(),
|
||||
websocket
|
||||
await addPurchase({
|
||||
database,
|
||||
familyId: userEntry.familyId,
|
||||
type,
|
||||
transactionId: 'manual-' + type + '-' + generatePurchaseId(),
|
||||
websocket,
|
||||
transaction
|
||||
})
|
||||
})
|
||||
|
||||
res.json({ ok: true })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue