Home Reference Source
import Session from 'neo4j-driver-core/lib/session.js'
public class | source

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

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 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 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.: {text: "MATCH ...", parameters: {param: 1}} or with the query and parameters as separate arguments.

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 Session#executeWrite instead.

Execute given unit of work in a WRITE transaction.

Public Methods

public [Symbol.asyncDispose](): * source

Return:

*

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:

NameTypeAttributeDescription
transactionConfig TransactionConfig
  • optional

Configuration for the new auto-commit transaction.

Return:

TransactionPromise

New Transaction.

public close(): Promise source

Close this session.

Return:

Promise

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.

Params:

NameTypeAttributeDescription
transactionWork function(tx: ManagedTransaction): Promise

Callback that executes operations against a given Transaction.

transactionConfig TransactionConfig
  • optional

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.

Params:

NameTypeAttributeDescription
transactionWork function(tx: ManagedTransaction): Promise

Callback that executes operations against a given Transaction.

transactionConfig TransactionConfig
  • optional

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

this method was deprecated. This method will be removed in version 6.0. Please, use Session#lastBookmarks instead.

Return the bookmarks received following the last completed Transaction.

Return:

string[]

A reference to a previous transaction.

See:

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

this method was deprecated. This method will be removed in version 6.0. Please, use Session#executeRead instead.

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:

NameTypeAttributeDescription
transactionWork function(tx: Transaction): Promise

Callback that executes operations against a given Transaction.

transactionConfig TransactionConfig
  • optional

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.

See:

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:

NameTypeAttributeDescription
query mixed

Cypher query to execute

parameters Object

Map with parameters to use in query

transactionConfig TransactionConfig
  • optional

Configuration for the new auto-commit transaction.

Return:

Result

New Result.

public writeTransaction(transactionWork: function(tx: Transaction): Promise, transactionConfig: TransactionConfig): Promise source

this method was deprecated. This method will be removed in version 6.0. Please, use Session#executeWrite instead.

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:

NameTypeAttributeDescription
transactionWork function(tx: Transaction): Promise

Callback that executes operations against a given Transaction.

transactionConfig TransactionConfig
  • optional

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.

See: