Skip to content

Commit

Permalink
Move create markets outside list transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Sep 25, 2024
1 parent 772cc88 commit 4893dab
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions packages/lists/lib/createList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ export async function createList({
throw new Error('User does not have enough balance to create list')
}

const createdList = await db.$transaction(async (tx) => {
const createdMarkets = await Promise.all(
markets.map((market) =>
createMarket({
question: market.name,
description: description ?? '',
options: [
{
name: 'Yes',
color: market.color ?? '#3B82F6',
},
{
name: 'No',
color: '#EC4899',
},
],
closeDate,
createdBy: ownerId,
subsidyAmount: costPerMarket,
})
)
const createdMarkets = await Promise.all(
markets.map((market) =>
createMarket({
question: market.name,
description: description ?? '',
options: [
{
name: 'Yes',
color: market.color ?? '#3B82F6',
},
{
name: 'No',
color: '#EC4899',
},
],
closeDate,
createdBy: ownerId,
subsidyAmount: costPerMarket,
})
)
)

const createdList = await db.$transaction(async (tx) => {
const list = await tx.list.create({
data: {
title,
Expand Down

0 comments on commit 4893dab

Please sign in to comment.