()
| 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({ |
no test coverage detected