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.
Defined in
packages/verse-core/src/db/driver.ts:147
info
get
info():DriverInfo
Retrieves the driver information.
Returns
The driver information.
Defined in
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
Parameter | Type | Description |
---|---|---|
logger | undefined | Logger | The logger instance to be used. Pass undefined to disable logging. |
Defined in
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.
Defined in
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.
Defined in
packages/verse-core/src/db/driver.ts:133
execute()
execute(
statements
: readonlyExecuteStatement
[],isolation
?:IsolationLevel
,onCommit
?: (results
: readonlyExecuteResult
[]) =>void
):Promise
<readonlyExecuteResult
[]>
Executes one or more SQL statements and returns the results.
Parameters
Parameter | Type | Description |
---|---|---|
statements | readonly ExecuteStatement [] | The SQL statements to execute. |
isolation ? | IsolationLevel | The isolation level for the transaction. |
onCommit ? | (results : readonly ExecuteResult []) => void | A 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.
Defined in
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.
Defined in
packages/verse-core/src/db/driver.ts:119
rows()
rows(
sql
:SqlNode
): (args
:unknown
[]) =>AsyncIterable
<readonlyunknown
[]>
Creates a function that can execute the given SQL query with the provided arguments and return an AsyncIterable of rows.
Parameters
Parameter | Type | Description |
---|---|---|
sql | SqlNode | The SQL query to execute. |
Returns
Function
A function that can execute the given SQL query.
Parameters
Parameter | Type |
---|---|
args | unknown [] |
Returns
AsyncIterable
<readonly unknown
[]>
Defined in
packages/verse-core/src/db/driver.ts:88
script()
script(
statements
: readonlyExecuteStatement
[]):string
[]
Generate a SQL script for the given statements.
Parameters
Parameter | Type | Description |
---|---|---|
statements | readonly ExecuteStatement [] | The SQL statements to generate the script for. |
Returns
string
[]
An array of strings representing the SQL script.
Defined in
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
Parameter | Type | Description |
---|---|---|
name | string | The name of the table to check. |
Returns
Promise
<boolean
>
A Promise resolving to a boolean value indicating whether the table exists.
Defined in
packages/verse-core/src/db/driver.ts:162
validate()
validate(
model
:Model
):void
Performs driver-specific validation of the model.
Parameters
Parameter | Type | Description |
---|---|---|
model | Model | The model to validate. |
Returns
void