Skip to main content
Module

x/neo4j_lite_client/core/index.ts>Session

Unofficial Neo4j Driver for Deno
Latest
class Session
Re-export
import { Session } from "https://deno.land/x/neo4j_lite_client@4.4.6/core/index.ts";

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.

Constructors

new
Session(unnamed 0: { mode: SessionMode; connectionProvider: ConnectionProvider; bookmark?: Bookmark; database: string; config: any; reactive: boolean; fetchSize: number; impersonatedUser?: string; })

Properties

private
_database: string
private
_databaseNameResolved: boolean
private
_fetchSize: number
private
_hasTx: boolean
private
optional
_impersonatedUser: string
private
_lastBookmark: Bookmark
private
_mode: SessionMode
private
_onComplete: (meta: any) => void
private
_open: boolean
private
_reactive: boolean
private
_readConnectionHolder: ConnectionHolder
private
_transactionExecutor: TransactionExecutor
private
_writeConnectionHolder: ConnectionHolder

Methods

_acquireConnection(connectionConsumer: ConnectionConsumer)
_beginTransaction(accessMode: SessionMode, txConfig: TxConfig): Transaction
_connectionHolderWithMode(mode: SessionMode): ConnectionHolder
_onCompleteCallback(meta: { bookmark: string | string[]; }): void
_onDatabaseNameResolved(database?: string): void

Sets the resolved database name in the session context.

_run(
query: Query,
parameters: any,
customRunner: ConnectionConsumer,
): Result
_runTransaction<T>(
accessMode: SessionMode,
transactionConfig: TxConfig,
transactionWork: TransactionWork<T>,
): Promise<T>
_updateBookmark(newBookmark?: Bookmark): void

Update value of the last bookmark.

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.

close(): Promise<void>

Close this session.

lastBookmark(): string[]

Return the bookmark received following the last completed Transaction.

readTransaction<T>(transactionWork: TransactionWork<T>, transactionConfig?: TransactionConfig): Promise<T>

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.

run(
query: Query,
parameters?: any,
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.

writeTransaction<T>(transactionWork: TransactionWork<T>, transactionConfig?: TransactionConfig): Promise<T>

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.

Static Methods

_validateSessionMode(rawMode?: SessionMode): SessionMode