More concise transaction in cancelbet

This commit is contained in:
Marshall Polaris 2022-07-12 13:26:33 -07:00
parent c2c4575462
commit b066ebc896

View File

@ -10,7 +10,7 @@ const bodySchema = z.object({
export const cancelbet = newEndpoint({}, async (req, auth) => { export const cancelbet = newEndpoint({}, async (req, auth) => {
const { betId } = validate(bodySchema, req.body) const { betId } = validate(bodySchema, req.body)
const result = await firestore.runTransaction(async (trans) => { return await firestore.runTransaction(async (trans) => {
const snap = await trans.get( const snap = await trans.get(
firestore.collectionGroup('bets').where('id', '==', betId) firestore.collectionGroup('bets').where('id', '==', betId)
) )
@ -28,8 +28,6 @@ export const cancelbet = newEndpoint({}, async (req, auth) => {
return { ...bet, isCancelled: true } return { ...bet, isCancelled: true }
}) })
return result
}) })
const firestore = admin.firestore() const firestore = admin.firestore()