File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ await client.batch(
15
15
16
16
const names = [ "John Doe" , "Mary Smith" , "Alice Jones" , "Mark Taylor" ] ;
17
17
18
+ let transaction , secondTransaction ;
18
19
try {
19
- const transaction = await client . transaction ( "write" ) ;
20
+ transaction = await client . transaction ( "write" ) ;
20
21
21
22
for ( const name of names ) {
22
23
await transaction . execute ( {
26
27
}
27
28
await transaction . rollback ( ) ;
28
29
29
- const secondTransaction = await client . transaction ( "write" ) ;
30
+ secondTransaction = await client . transaction ( "write" ) ;
30
31
31
32
for ( const name of names ) {
32
33
await secondTransaction . execute ( {
38
39
await secondTransaction . commit ( ) ;
39
40
} catch ( e ) {
40
41
console . error ( e ) ;
41
- await transaction . rollback ( ) ;
42
- await secondTransaction . rollback ( ) ;
42
+ await transaction ? .rollback ( ) ;
43
+ await secondTransaction ? .rollback ( ) ;
43
44
}
44
45
45
46
const result = await client . execute ( "SELECT * FROM users" ) ;
You can’t perform that action at this time.
0 commit comments