Class: Connection

Connection(database, numThreads)

new Connection(database, numThreads)

Initialize a new Connection object. Note that the initialization is done lazily, so the connection is not initialized until the first query is executed. To initialize the connection immediately, call the `init()` function on the returned object.
Parameters:
Name Type Default Description
database kuzu.Database the database object to connect to.
numThreads Number null the maximum number of threads to use for query execution.
Source:

Methods

(async) _getConnection() → {KuzuNative.NodeConnection}

Internal function to get the underlying native connection object.
Source:
Returns:
the underlying native connection.
Type
KuzuNative.NodeConnection

_getNextQueryResult(nodeQueryResult) → {Promise.<kuzu.QueryResult>}

Internal function to get the next query result for multiple query results.
Parameters:
Name Type Description
nodeQueryResult KuzuNative.NodeQueryResult the current node query result.
Source:
Returns:
a promise that resolves to the next query result. The promise is rejected if there is an error.
Type
Promise.<kuzu.QueryResult>

(async) _unwrapMultipleQueryResults(nodeQueryResult) → {Promise.<Array.<kuzu.QueryResult>>|kuzu.QueryResult}

Internal function to unwrap multiple query results into an array of query results.
Parameters:
Name Type Description
nodeQueryResult KuzuNative.NodeQueryResult the node query result.
Source:
Returns:
a promise that resolves to an array of query results. The promise is rejected if there is an error.
Type
Promise.<Array.<kuzu.QueryResult>> | kuzu.QueryResult

(async) close()

Close the connection. Note: Call to this method is optional. The connection will be closed automatically when the object goes out of scope.
Source:

execute(preparedStatement, params, progressCallbackopt) → {Promise.<kuzu.QueryResult>}

Execute a prepared statement with the given parameters.
Parameters:
Name Type Attributes Description
preparedStatement kuzu.PreparedStatement the prepared statement to execute.
params Object a plain object mapping parameter names to values.
progressCallback function <optional>
Optional callback function that is invoked with the progress of the query execution. The callback receives three arguments: pipelineProgress, numPipelinesFinished, and numPipelines.
Source:
Returns:
a promise that resolves to the query result. The promise is rejected if there is an error.
Type
Promise.<kuzu.QueryResult>

(async) init()

Initialize the connection. Calling this function is optional, as the connection is initialized automatically when the first query is executed.
Source:

prepare(statement) → {Promise.<kuzu.PreparedStatement>}

Prepare a statement for execution.
Parameters:
Name Type Description
statement String the statement to prepare.
Source:
Returns:
a promise that resolves to the prepared statement. The promise is rejected if there is an error.
Type
Promise.<kuzu.PreparedStatement>

query(statement, progressCallbackopt) → {Promise.<kuzu.QueryResult>}

Execute a query.
Parameters:
Name Type Attributes Description
statement String the statement to execute.
progressCallback function <optional>
Optional callback function that is invoked with the progress of the query execution. The callback receives three arguments: pipelineProgress, numPipelinesFinished, and numPipelines.
Source:
Returns:
a promise that resolves to the query result. The promise is rejected if there is an error.
Type
Promise.<kuzu.QueryResult>

setMaxNumThreadForExec(numThreads)

Set the maximum number of threads to use for query execution.
Parameters:
Name Type Description
numThreads Number the maximum number of threads to use for query execution.
Source:

setQueryTimeout(timeoutInMs)

Set the timeout for queries. Queries that take longer than the timeout will be aborted.
Parameters:
Name Type Description
timeoutInMs Number the timeout in milliseconds.
Source: