17
17
* limitations under the License.
18
18
*/
19
19
20
- import Session from "../../../types/v1/session" ;
20
+ import Session , { TransactionConfig } from "../../../types/v1/session" ;
21
21
import Transaction from "../../../types/v1/transaction" ;
22
22
import Record from "../../../types/v1/record" ;
23
23
import Result , { StatementResult } from "../../../types/v1/result" ;
24
24
import ResultSummary from "../../../types/v1/result-summary" ;
25
+ import Integer from "../../../types/v1/integer" ;
25
26
26
27
const dummy : any = null ;
28
+ const intValue : Integer = Integer . fromInt ( 42 ) ;
27
29
28
30
const session : Session = dummy ;
29
31
30
- const tx : Transaction = session . beginTransaction ( ) ;
32
+ const txConfig1 : TransactionConfig = { } ;
33
+ const txConfig2 : TransactionConfig = { timeout : 5000 } ;
34
+ const txConfig3 : TransactionConfig = { timeout : intValue } ;
35
+ const txConfig4 : TransactionConfig = { metadata : { } } ;
36
+ const txConfig5 : TransactionConfig = { metadata : { key1 : 'value1' , key2 : 5 , key3 : { a : 'a' , b : 'b' } , key4 : [ 1 , 2 , 3 ] } } ;
37
+ const txConfig6 : TransactionConfig = { timeout : 2000 , metadata : { key1 : 'value1' , key2 : 2 } } ;
38
+ const txConfig7 : TransactionConfig = { timeout : intValue , metadata : { key1 : 'value1' , key2 : 2 } } ;
39
+
40
+ const tx1 : Transaction = session . beginTransaction ( ) ;
31
41
const bookmark : null | string = < null > session . lastBookmark ( ) ;
32
42
33
43
const promise1 : Promise < number > = session . readTransaction ( ( tx : Transaction ) => {
@@ -101,7 +111,7 @@ result4.subscribe({
101
111
onCompleted : ( summary : ResultSummary ) => console . log ( summary )
102
112
} ) ;
103
113
104
- const result5 : Result = session . run ( { text : "RETURN 1" } ) ;
114
+ const result5 : Result = session . run ( "RETURN $value" , { value : "42" } , txConfig1 ) ;
105
115
result5 . then ( ( res : StatementResult ) => {
106
116
const records : Record [ ] = res . records ;
107
117
const summary : ResultSummary = res . summary ;
@@ -111,7 +121,7 @@ result5.then((res: StatementResult) => {
111
121
console . log ( error ) ;
112
122
} ) ;
113
123
114
- const result6 : Result = session . run ( { text : "RETURN 1" } ) ;
124
+ const result6 : Result = session . run ( "RETURN $value" , { value : "42" } , txConfig2 ) ;
115
125
result6 . subscribe ( { } ) ;
116
126
result6 . subscribe ( {
117
127
onNext : ( record : Record ) => console . log ( record )
@@ -126,27 +136,6 @@ result6.subscribe({
126
136
onCompleted : ( summary : ResultSummary ) => console . log ( summary )
127
137
} ) ;
128
138
129
- const result7 : Result = session . run ( { text : "RETURN $value" , parameters : { value : 42 } } ) ;
130
- result7 . then ( ( res : StatementResult ) => {
131
- const records : Record [ ] = res . records ;
132
- const summary : ResultSummary = res . summary ;
133
- console . log ( records ) ;
134
- console . log ( summary ) ;
135
- } ) . catch ( ( error : Error ) => {
136
- console . log ( error ) ;
137
- } ) ;
138
-
139
- const result8 : Result = session . run ( { text : "RETURN $value" , parameters : { value : 42 } } ) ;
140
- result8 . subscribe ( { } ) ;
141
- result8 . subscribe ( {
142
- onNext : ( record : Record ) => console . log ( record )
143
- } ) ;
144
- result8 . subscribe ( {
145
- onNext : ( record : Record ) => console . log ( record ) ,
146
- onError : ( error : Error ) => console . log ( error )
147
- } ) ;
148
- result8 . subscribe ( {
149
- onNext : ( record : Record ) => console . log ( record ) ,
150
- onError : ( error : Error ) => console . log ( error ) ,
151
- onCompleted : ( summary : ResultSummary ) => console . log ( summary )
152
- } ) ;
139
+ const tx2 : Transaction = session . beginTransaction ( txConfig2 ) ;
140
+ const promise5 : Promise < string > = session . readTransaction ( ( tx : Transaction ) => "" , txConfig3 ) ;
141
+ const promise6 : Promise < number > = session . writeTransaction ( ( tx : Transaction ) => 42 , txConfig4 ) ;
0 commit comments