@auth/neo4j-adapter
Official Neo4j adapter for Auth.js / NextAuth.js.
Installation
npm install @auth/neo4j-adapter neo4j-driver
Neo4jOptions
This is the interface of the Neo4j adapter options. The Neo4j adapter takes a Neo4j session as its only argument.
Extends
Session
Methods
_beginTransaction()
_beginTransaction(
accessMode,
txConfig,
apiTelemetryConfig?): TransactionPromise
Parameters
Parameter | Type |
---|---|
accessMode | SessionMode |
txConfig | TxConfig |
apiTelemetryConfig ? | NonAutoCommitApiTelemetryConfig |
Returns
TransactionPromise
Inherited from
Session._beginTransaction
_connectionHolderWithMode()
_connectionHolderWithMode(mode): ConnectionHolder
Parameters
Parameter | Type |
---|---|
mode | SessionMode |
Returns
ConnectionHolder
Inherited from
Session._connectionHolderWithMode
_run()
_run<T>(
query,
parameters,
customRunner): Result
Type Parameters
Type Parameter | Default type |
---|---|
T extends ResultStreamObserver | ResultStreamObserver |
Parameters
Parameter | Type |
---|---|
query | Query |
parameters | any |
customRunner | ConnectionConsumer <T > |
Returns
Result
Inherited from
Session._run
_runTransaction()
_runTransaction<T>(
accessMode,
transactionConfig,
transactionWork): Promise<T>
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
accessMode | SessionMode |
transactionConfig | TxConfig |
transactionWork | TransactionWork <T > |
Returns
Promise
<T
>
Inherited from
Session._runTransaction
beginTransaction()
beginTransaction(transactionConfig?): TransactionPromise
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.
Parameters
Parameter | Type | Description |
---|---|---|
transactionConfig ? | TransactionConfig | Configuration for the new auto-commit transaction. |
Returns
TransactionPromise
New Transaction.
Inherited from
Session.beginTransaction
close()
close(): Promise<void>
Close this session.
Returns
Promise
<void
>
Inherited from
Session.close
executeRead()
executeRead<T>(transactionWork, 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.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
transactionWork | ManagedTransactionWork <T > | Callback that executes operations against a given Transaction. |
transactionConfig ? | TransactionConfig | Configuration for all transactions started to execute the unit of work. |
Returns
Promise
<T
>
Resolved promise as returned by the given function or rejected promise when given function or commit fails.
Inherited from
Session.executeRead
executeWrite()
executeWrite<T>(transactionWork, 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.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
transactionWork | ManagedTransactionWork <T > | Callback that executes operations against a given Transaction. |
transactionConfig ? | TransactionConfig | Configuration for all transactions started to execute the unit of work. |
Returns
Promise
<T
>
Resolved promise as returned by the given function or rejected promise when given function or commit fails.
Inherited from
Session.executeWrite
lastBookmark()
lastBookmark(): string[]
Return the bookmarks received following the last completed Transaction.
Returns
string
[]
A reference to a previous transaction.
Deprecated
This method will be removed in version 6.0. Please, use Session#lastBookmarks instead.
See
Inherited from
Session.lastBookmark
lastBookmarks()
lastBookmarks(): string[]
Return the bookmarks received following the last completed Transaction.
Returns
string
[]
A reference to a previous transaction.
Inherited from
Session.lastBookmarks
readTransaction()
readTransaction<T>(transactionWork, 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.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
transactionWork | TransactionWork <T > | Callback that executes operations against a given Transaction. |
transactionConfig ? | TransactionConfig | Configuration for all transactions started to execute the unit of work. |
Returns
Promise
<T
>
Resolved promise as returned by the given function or rejected promise when given function or commit fails.
Deprecated
This method will be removed in version 6.0. Please, use Session#executeRead instead.
See
Inherited from
Session.readTransaction
run()
run<R>(
query,
parameters?,
transactionConfig?): Result<R>
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.
Type Parameters
Type Parameter | Default type |
---|---|
R extends RecordShape | RecordShape |
Parameters
Parameter | Type | Description |
---|---|---|
query | Query | Cypher query to execute |
parameters ? | any | Map with parameters to use in query |
transactionConfig ? | TransactionConfig | Configuration for the new auto-commit transaction. |
Returns
Result
<R
>
New Result.
Inherited from
Session.run
writeTransaction()
writeTransaction<T>(transactionWork, 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.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
transactionWork | TransactionWork <T > | Callback that executes operations against a given Transaction. |
transactionConfig ? | TransactionConfig | Configuration for all transactions started to execute the unit of work. |
Returns
Promise
<T
>
Resolved promise as returned by the given function or rejected promise when given function or commit fails.
Deprecated
This method will be removed in version 6.0. Please, use Session#executeWrite instead.
See
Inherited from
Session.writeTransaction
format
const format: {
from: null | T;
to: Record<string, unknown>;
};
Type declaration
from()
Takes a Neo4j object and returns a plain old JavaScript object
Type Parameters
Type Parameter | Default type |
---|---|
T | Record <string , unknown > |
Parameters
Parameter | Type |
---|---|
object ? | Record <string , any > |
Returns
null
| T
to()
Takes a plain old JavaScript object and turns it into a Neo4j compatible object
Parameters
Parameter | Type |
---|---|
object | Record <string , any > |
Returns
Record
<string
, unknown
>
Neo4jAdapter()
function Neo4jAdapter(session): Adapter
Parameters
Parameter | Type |
---|---|
session | Session |