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

Driver

Direct Subclass:

src/routing-driver.js~RoutingDriver

A driver maintains one or more Sessions with a remote Neo4j instance. Through the Sessions you can send queries and retrieve results from the database.

Drivers are reasonably expensive to create - you should strive to keep one driver instance around per Neo4j Instance you connect to.

Method Summary

Public Methods
public

close(): Promise<void>

Close all open sessions and other associated resources.

public

rxSession(param: Object): RxSession

Acquire a reactive session to communicate with the database.

public

session(param: Object): Session

Acquire a session to communicate with the database.

public

supportsMultiDb(): Promise<boolean>

Returns whether the server supports multi database capabilities based on the protocol version negotiated via handshake.

public

supportsTransactionConfig(): Promise<boolean>

Returns whether the server supports transaction config capabilities based on the protocol version negotiated via handshake.

public

verifyConnectivity(param: Object): Promise<void>

Verifies connectivity of this driver by trying to open a connection with the provided driver options.

Public Methods

public close(): Promise<void> source

Close all open sessions and other associated resources. You should make sure to use this when you are done with this driver instance.

Return:

Promise<void>

promise resolved when the driver is closed.

public rxSession(param: Object): RxSession source

Acquire a reactive session to communicate with the database. The session will borrow connections from the underlying connection pool as required and should be considered lightweight and disposable.

This comes with some responsibility - make sure you always call close when you are done using a session, and likewise, make sure you don't close your session before you are done using it. Once it is closed, the underlying connection will be released to the connection pool and made available for others to use.

Params:

NameTypeAttributeDescription
param Object
param.defaultAccessMode string
  • default: WRITE

The access mode of this session, allowed values are READ and WRITE.

param.bookmarks string | string[]

The initial reference or references to some previous transactions. Value is optional and absence indicates that the bookmarks do not exist or are unknown.

param.database string

The database this session will operate on.

Return:

RxSession

new reactive session.

public session(param: Object): Session source

Acquire a session to communicate with the database. The session will borrow connections from the underlying connection pool as required and should be considered lightweight and disposable.

This comes with some responsibility - make sure you always call close when you are done using a session, and likewise, make sure you don't close your session before you are done using it. Once it is closed, the underlying connection will be released to the connection pool and made available for others to use.

Params:

NameTypeAttributeDescription
param Object

The object parameter

param.defaultAccessMode string
  • default: WRITE

The access mode of this session, allowed values are READ and WRITE.

param.bookmarks string | string[]

The initial reference or references to some previous transactions. Value is optional and absence indicates that that the bookmarks do not exist or are unknown.

param.fetchSize number

The record fetch size of each batch of this session. Use ALL to always pull all records in one batch. This will override the config value set on driver config.

param.database string

The database this session will operate on.

Return:

Session

new session.

public supportsMultiDb(): Promise<boolean> source

Returns whether the server supports multi database capabilities based on the protocol version negotiated via handshake.

Note that this function call always causes a round-trip to the server.

Return:

Promise<boolean>

promise resolved with a boolean or rejected with error.

public supportsTransactionConfig(): Promise<boolean> source

Returns whether the server supports transaction config capabilities based on the protocol version negotiated via handshake.

Note that this function call always causes a round-trip to the server.

Return:

Promise<boolean>

promise resolved with a boolean or rejected with error.

public verifyConnectivity(param: Object): Promise<void> source

Verifies connectivity of this driver by trying to open a connection with the provided driver options.

Params:

NameTypeAttributeDescription
param Object

The object parameter

param.database string

The target database to verify connectivity for.

Return:

Promise<void>

promise resolved with server info or rejected with error.