Felipe Belinassi
06/23/2021, 12:45 PMconst data = await prisma.model.create({
data: {
id: (await prisma.model.count()) + 1,
...params,
},
});
Is there other way for doing this?Nichita Z
06/23/2021, 12:47 PMNichita Z
06/23/2021, 12:48 PMFelipe Belinassi
06/23/2021, 12:54 PMatomicOperations
only work for update operations =/
I need to do something like that but for create
onesRyan
06/23/2021, 12:57 PMFelipe Belinassi
06/23/2021, 1:30 PMconst insertNextVal = (prisma, model, values) => {
const createEntry = prisma[model].create({
id: (await prisma.model.count()) + 1,
...values
})
return prisma.$transaction([createEntry]);
}
Ryan
06/23/2021, 1:44 PMawait
inside will always be run outside the transaction. A raw query is the only way for now.Felipe Belinassi
06/23/2021, 1:52 PMcount
part or for everything (whole query as raw)?Ryan
06/23/2021, 2:07 PM