Skip to main content

Interface: Driver

The contract between Verse core and a relational database client.

Accessors

conventions

get conventions(): List <Convention>

Conventions used by the driver.

Returns

List <Convention>

A list of conventions.

Source

packages/verse-core/src/db/driver.ts:147


info

get info(): DriverInfo

Retrieves the driver information.

Returns

DriverInfo

The driver information.

Source

packages/verse-core/src/db/driver.ts:154


logger

set logger(logger: undefined | Logger): void

Set the Logger to be used for logging events.

Parameters

ParameterTypeDescription
loggerundefined | LoggerThe logger instance to be used. Pass undefined to disable logging.

Source

packages/verse-core/src/db/driver.ts:140

Methods

create()

create(): Promise ↗️<void>

Creates the target database.

Returns

Promise ↗️<void>

A Promise that resolves with no value when the operation is complete.

Source

packages/verse-core/src/db/driver.ts:126


drop()

drop(): Promise ↗️<void>

Drops the target database.

Returns

Promise ↗️<void>

A Promise that resolves with no value when the operation is complete.

Source

packages/verse-core/src/db/driver.ts:133


execute()

execute(statements: readonly ExecuteStatement[], isolation?: IsolationLevel, onCommit?: (results: readonly ExecuteResult[]) => void): Promise ↗️<readonly ExecuteResult[]>

Executes one or more SQL statements and returns the results.

Parameters

ParameterTypeDescription
statementsreadonly ExecuteStatement[]The SQL statements to execute.
isolation?IsolationLevelThe isolation level for the transaction.
onCommit?(results: readonly ExecuteResult[]) => voidA callback function to be called on committing the transaction.
Receives an array of ExecuteResult objects as parameter.

Returns

Promise ↗️<readonly ExecuteResult[]>

A Promise that resolves to an array of ExecuteResult objects representing the results of executing the statements.

Source

packages/verse-core/src/db/driver.ts:100


exists()

exists(): Promise ↗️<boolean>

Checks if the target database exists.

Returns

Promise ↗️<boolean>

A Promise that resolves to true if the database exists; otherwise, false.

Source

packages/verse-core/src/db/driver.ts:119


rows()

rows(sql: SqlNode): (args: unknown[]) => AsyncIterable<readonly unknown[]>

Creates a function that can execute the given SQL query with the provided arguments and return an AsyncIterable of rows.

Parameters

ParameterTypeDescription
sqlSqlNodeThe SQL query to execute.

Returns

Function

A function that can execute the given SQL query.

Parameters
ParameterType
argsunknown[]
Returns

AsyncIterable<readonly unknown[]>

Source

packages/verse-core/src/db/driver.ts:88


script()

script(statements: readonly ExecuteStatement[]): string[]

Generate a SQL script for the given statements.

Parameters

ParameterTypeDescription
statementsreadonly ExecuteStatement[]The SQL statements to generate the script for.

Returns

string[]

An array of strings representing the SQL script.

Source

packages/verse-core/src/db/driver.ts:112


tableExists()

tableExists(name: string): Promise ↗️<boolean>

Checks whether a table with the given name exists in the target database.

Parameters

ParameterTypeDescription
namestringThe name of the table to check.

Returns

Promise ↗️<boolean>

A Promise resolving to a boolean value indicating whether the table exists.

Source

packages/verse-core/src/db/driver.ts:162


validate()

validate(model: Model): void

Performs driver-specific validation of the model.

Parameters

ParameterTypeDescription
modelModelThe model to validate.

Returns

void

Source

packages/verse-core/src/db/driver.ts:169