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

Transaction

Represents a transaction in the Neo4j database.

Constructor Summary

Public Constructor
public

constructor(connectionHolder: ConnectionHolder, onClose: function(), onBookmark: function(bookmark: Bookmark), reactive: boolean, fetchSize: number)

Method Summary

Public Methods
public

commit(): Promise<void>

Commits the transaction and returns the result.

public

isOpen(): boolean

Check if this transaction is active, which means commit and rollback did not happen.

public

rollback(): Promise<void>

Rollbacks the transaction.

public

run(query: mixed, parameters: Object): 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 Constructors

public constructor(connectionHolder: ConnectionHolder, onClose: function(), onBookmark: function(bookmark: Bookmark), reactive: boolean, fetchSize: number) source

Params:

NameTypeAttributeDescription
connectionHolder ConnectionHolder

the connection holder to get connection from.

onClose function()

Function to be called when transaction is committed or rolled back.

onBookmark function(bookmark: Bookmark)

callback invoked when new bookmark is produced.

  • @param {function()} onConnection - Function to be called when a connection is obtained to ensure the conneciton is not yet released.
reactive boolean

whether this transaction generates reactive streams

fetchSize number

the record fetch size in each pulling batch.

Public Methods

public commit(): Promise<void> source

Commits the transaction and returns the result.

After committing the transaction can no longer be used.

Return:

Promise<void>

An empty promise if committed successfully or error if any error happened during commit.

public isOpen(): boolean source

Check if this transaction is active, which means commit and rollback did not happen.

Return:

boolean

true when not committed and not rolled back, false otherwise.

public rollback(): Promise<void> source

Rollbacks the transaction.

After rolling back, the transaction can no longer be used.

Return:

Promise<void>

An empty promise if rolled back successfully or error if any error happened during rollback.

public run(query: mixed, parameters: Object): 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

Return:

Result

New Result