File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,12 @@ class Transaction {
107
107
this . _state = committed . state
108
108
// clean up
109
109
this . _onClose ( )
110
- return committed . result
110
+ return new Promise ( ( resolve , reject ) => {
111
+ committed . result . subscribe ( {
112
+ onCompleted : ( ) => resolve ( ) ,
113
+ onError : error => reject ( error )
114
+ } )
115
+ } )
111
116
}
112
117
113
118
/**
@@ -118,15 +123,20 @@ class Transaction {
118
123
* @returns {Result } New Result
119
124
*/
120
125
rollback ( ) {
121
- let committed = this . _state . rollback ( {
126
+ let rolledback = this . _state . rollback ( {
122
127
connectionHolder : this . _connectionHolder ,
123
128
onError : this . _onError ,
124
129
onComplete : this . _onComplete
125
130
} )
126
- this . _state = committed . state
131
+ this . _state = rolledback . state
127
132
// clean up
128
133
this . _onClose ( )
129
- return committed . result
134
+ return new Promise ( ( resolve , reject ) => {
135
+ rolledback . result . subscribe ( {
136
+ onCompleted : ( ) => resolve ( ) ,
137
+ onError : error => reject ( error )
138
+ } )
139
+ } )
130
140
}
131
141
132
142
/**
Original file line number Diff line number Diff line change 19
19
import neo4j from '../src'
20
20
import sharedNeo4j from './internal/shared-neo4j'
21
21
import { ServerVersion } from '../src/internal/server-version'
22
+ import TxConfig from '../src/internal/tx-config'
22
23
23
24
describe ( '#integration transaction' , ( ) => {
24
25
let driver
@@ -571,6 +572,20 @@ describe('#integration transaction', () => {
571
572
} )
572
573
} )
573
574
575
+ it ( 'should return empty promise on commit' , async ( ) => {
576
+ const tx = session . beginTransaction ( )
577
+ const result = await tx . commit ( )
578
+
579
+ expect ( result ) . toBeUndefined ( )
580
+ } )
581
+
582
+ it ( 'should return empty promise on rollback' , async ( ) => {
583
+ const tx = session . beginTransaction ( )
584
+ const result = await tx . rollback ( )
585
+
586
+ expect ( result ) . toBeUndefined ( )
587
+ } )
588
+
574
589
function expectSyntaxError ( error ) {
575
590
expect ( error . code ) . toBe ( 'Neo.ClientError.Statement.SyntaxError' )
576
591
}
You can’t perform that action at this time.
0 commit comments