Session
A Session instance is used for handling the connection and sending queries through the connection. In a single session, multiple queries will be executed serially. In order to execute parallel queries, multiple sessions are required.
Method Summary
Public Methods | ||
public |
|
|
public |
beginTransaction(transactionConfig: TransactionConfig): TransactionPromise Begin a new transaction in this session. |
|
public |
close(): Promise Close this session. |
|
public |
executeRead(transactionWork: function(tx: ManagedTransaction): Promise, transactionConfig: TransactionConfig): Promise Execute given unit of work in a READ transaction. |
|
public |
executeWrite(transactionWork: function(tx: ManagedTransaction): Promise, transactionConfig: TransactionConfig): Promise Execute given unit of work in a WRITE transaction. |
|
public |
lastBookmark(): string[] this method was deprecated. This method will be removed in version 6.0. Please, use {@link Session#lastBookmarks} instead.
Return the bookmarks received following the last completed Transaction. |
|
public |
lastBookmarks(): string[] Return the bookmarks received following the last completed Transaction. |
|
public |
readTransaction(transactionWork: function(tx: Transaction): Promise, transactionConfig: TransactionConfig): Promise this method was deprecated. This method will be removed in version 6.0. Please, use {@link Session#executeRead} instead.
Execute given unit of work in a READ transaction. |
|
public |
run(query: mixed, parameters: Object, transactionConfig: TransactionConfig): Result Run Cypher query
Could be called with a query object i.e.: |
|
public |
writeTransaction(transactionWork: function(tx: Transaction): Promise, transactionConfig: TransactionConfig): Promise this method was deprecated. This method will be removed in version 6.0. Please, use {@link Session#executeWrite} instead.
Execute given unit of work in a WRITE transaction. |
Public Methods
public beginTransaction(transactionConfig: TransactionConfig): TransactionPromise source
Begin a new transaction in this session. A session can have at most one transaction running at a time, if you want to run multiple concurrent transactions, you should use multiple concurrent sessions.
While a transaction is open the session cannot be used to run queries outside the transaction.
Params:
Name | Type | Attribute | Description |
transactionConfig | TransactionConfig |
|
Configuration for the new auto-commit transaction. |
public executeRead(transactionWork: function(tx: ManagedTransaction): Promise, transactionConfig: TransactionConfig): Promise source
Execute given unit of work in a READ transaction.
Transaction will automatically be committed unless the given function throws or returns a rejected promise.
Some failures of the given function or the commit itself will be retried with exponential backoff with initial
delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
maxTransactionRetryTime
property in milliseconds.
NOTE: Because it is an explicit transaction from the server point of view, Cypher queries using "CALL {} IN TRANSACTIONS" or the older "USING PERIODIC COMMIT" construct will not work (call Session#run for these).
Params:
Name | Type | Attribute | Description |
transactionWork | function(tx: ManagedTransaction): Promise | Callback that executes operations against a given Transaction. |
|
transactionConfig | TransactionConfig |
|
Configuration for all transactions started to execute the unit of work. |
Return:
Promise | Resolved promise as returned by the given function or rejected promise when given function or commit fails. |
public executeWrite(transactionWork: function(tx: ManagedTransaction): Promise, transactionConfig: TransactionConfig): Promise source
Execute given unit of work in a WRITE transaction.
Transaction will automatically be committed unless the given function throws or returns a rejected promise.
Some failures of the given function or the commit itself will be retried with exponential backoff with initial
delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
maxTransactionRetryTime
property in milliseconds.
NOTE: Because it is an explicit transaction from the server point of view, Cypher queries using "CALL {} IN TRANSACTIONS" or the older "USING PERIODIC COMMIT" construct will not work (call Session#run for these).
Params:
Name | Type | Attribute | Description |
transactionWork | function(tx: ManagedTransaction): Promise | Callback that executes operations against a given Transaction. |
|
transactionConfig | TransactionConfig |
|
Configuration for all transactions started to execute the unit of work. |
Return:
Promise | Resolved promise as returned by the given function or rejected promise when given function or commit fails. |
public lastBookmark(): string[] source
Return the bookmarks received following the last completed Transaction.
Return:
string[] | A reference to a previous transaction. |
public lastBookmarks(): string[] source
Return the bookmarks received following the last completed Transaction.
Return:
string[] | A reference to a previous transaction. |
public readTransaction(transactionWork: function(tx: Transaction): Promise, transactionConfig: TransactionConfig): Promise source
Execute given unit of work in a READ transaction.
Transaction will automatically be committed unless the given function throws or returns a rejected promise.
Some failures of the given function or the commit itself will be retried with exponential backoff with initial
delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
maxTransactionRetryTime
property in milliseconds.
Params:
Name | Type | Attribute | Description |
transactionWork | function(tx: Transaction): Promise | Callback that executes operations against a given Transaction. |
|
transactionConfig | TransactionConfig |
|
Configuration for all transactions started to execute the unit of work. |
Return:
Promise | Resolved promise as returned by the given function or rejected promise when given function or commit fails. |
public run(query: mixed, parameters: Object, transactionConfig: TransactionConfig): Result source
Run Cypher query
Could be called with a query object i.e.: {text: "MATCH ...", parameters: {param: 1}}
or with the query and parameters as separate arguments.
Params:
Name | Type | Attribute | Description |
query | mixed | Cypher query to execute |
|
parameters | Object | Map with parameters to use in query |
|
transactionConfig | TransactionConfig |
|
Configuration for the new auto-commit transaction. |
public writeTransaction(transactionWork: function(tx: Transaction): Promise, transactionConfig: TransactionConfig): Promise source
Execute given unit of work in a WRITE transaction.
Transaction will automatically be committed unless the given function throws or returns a rejected promise.
Some failures of the given function or the commit itself will be retried with exponential backoff with initial
delay of 1 second and maximum retry time of 30 seconds. Maximum retry time is configurable via driver config's
maxTransactionRetryTime
property in milliseconds.
Params:
Name | Type | Attribute | Description |
transactionWork | function(tx: Transaction): Promise | Callback that executes operations against a given Transaction. |
|
transactionConfig | TransactionConfig |
|
Configuration for all transactions started to execute the unit of work. |
Return:
Promise | Resolved promise as returned by the given function or rejected promise when given function or commit fails. |