MCPcopy
hub / github.com/prisma/prisma / interactiveTransactions

Method interactiveTransactions

sandbox/driver-adapters/src/test.ts:115–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 }
114
115 async interactiveTransactions() {
116 const author = await this.prisma.author.create({
117 data: {
118 firstName: 'Firstname 1 from autoincrement',
119 lastName: 'Lastname 1 from autoincrement',
120 age: 99,
121 },
122 })
123 console.log('[nodejs] author', superjson.serialize(author).json)
124
125 const result = await this.prisma.$transaction(async (tx) => {
126 await tx.author.deleteMany()
127 await tx.post.deleteMany()
128
129 const author = await tx.author.create({
130 data: {
131 firstName: 'Firstname 2 from autoincrement',
132 lastName: 'Lastname 2 from autoincrement',
133 age: 100,
134 },
135 })
136 const post = await tx.post.create({
137 data: {
138 title: 'Title from transaction',
139 published: false,
140 author: {
141 connect: {
142 id: author.id,
143 },
144 },
145 },
146 })
147 return { author, post }
148 })
149
150 console.log('[nodejs] result', superjson.serialize(result).json)
151 }
152
153 async testTypeTest2() {
154 const created = await this.prisma.type_test_2.create({

Callers 1

smokeTestFunction · 0.95

Calls 4

logMethod · 0.80
serializeMethod · 0.80
$transactionMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected