Interface: QueryClientContract
Shape of the query client, that is used to retrieve instances of query builder
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
connectionName | readonly | string | The name of the connection from which the client was originated |
debug | public | boolean | Is debug enabled on the connection or not. Also opens up the API to disable debug for a given client |
dialect | readonly | DialectContract | The database dialect in use |
emitter | public | Emitter<any> | - |
from | public | FromTable<DatabaseQueryBuilderContract<any>> | Same as query(), but also selects the table for the query. The from method doesn't allow defining the return type and one must use query to define that. |
isTransaction | readonly | boolean | Tells if client is a transaction client or not |
mode | readonly | "dual" | "write" | "read" | The client mode in which it is execute queries |
schema | public | SchemaBuilder | Returns schema instance for the write client |
table | public | <ReturnColumns>(table: string) => InsertQueryBuilderContract<ReturnColumns[]> | Same as insertQuery(), but also selects the table for the query. The table method doesn't allow defining the return type and one must use insertQuery to define that. |
transaction | public | TransactionFn | Get instance of transaction client |
Methods
columnsInfo()
Call Signature
columnsInfo(table: string): Promise<{
[column: string]: ColumnInfo;
}>;Returns columns info for a given table
Parameters
| Parameter | Type |
|---|---|
table | string |
Returns
Promise<{ [column: string]: ColumnInfo; }>
Call Signature
columnsInfo(table: string, column: string): Promise<ColumnInfo>;Parameters
| Parameter | Type |
|---|---|
table | string |
column | string |
Returns
Promise<ColumnInfo>
dropAllDomains()
dropAllDomains(schemas?: string[]): Promise<void>;Drop all domains inside the database
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<void>
dropAllTables()
dropAllTables(schemas?: string[]): Promise<void>;Drop all tables inside database
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<void>
dropAllTypes()
dropAllTypes(schemas?: string[]): Promise<void>;Drop all types inside the database
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<void>
dropAllViews()
dropAllViews(schemas?: string[]): Promise<void>;Drop all views inside the database
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<void>
getAdvisoryLock()
getAdvisoryLock(key: string | number, timeout?: number): Promise<boolean>;Work with advisory locks
Parameters
| Parameter | Type |
|---|---|
key | string | number |
timeout? | number |
Returns
Promise<boolean>
getAllDomains()
getAllDomains(schemas?: string[]): Promise<string[]>;Returns an array of all domain names
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<string[]>
getAllTables()
getAllTables(schemas?: string[]): Promise<string[]>;Get all tables of the database
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<string[]>
getAllTypes()
getAllTypes(schemas?: string[]): Promise<string[]>;Returns an array of all types names
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<string[]>
getAllViews()
getAllViews(schemas?: string[]): Promise<string[]>;Returns an array of all views names for one or many schemas
Parameters
| Parameter | Type |
|---|---|
schemas? | string[] |
Returns
Promise<string[]>
getReadClient()
getReadClient(): Knex<any, any>;Returns the read and write clients
Returns
Knex<any, any>
getWriteClient()
getWriteClient(): Knex<any, any>;Returns
Knex<any, any>
insertQuery()
insertQuery<ReturnColumns>(): InsertQueryBuilderContract<ReturnColumns[]>;Get new query builder instance inserts
Type Parameters
| Type Parameter | Default type |
|---|---|
ReturnColumns | any |
Returns
InsertQueryBuilderContract<ReturnColumns[]>
knexQuery()
knexQuery(): QueryBuilder;Returns the knex query builder instance
Returns
QueryBuilder
knexRawQuery()
knexRawQuery(sql: string, bindings?: RawQueryBindings): Raw;Returns the knex raw query builder instance
Parameters
| Parameter | Type |
|---|---|
sql | string |
bindings? | RawQueryBindings |
Returns
Raw
modelQuery()
modelQuery<T, Result>(model: T): ModelQueryBuilderContract<T, Result>;Returns the query builder for a given model
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends LucidModel | - |
Result | T |
Parameters
| Parameter | Type |
|---|---|
model | T |
Returns
ModelQueryBuilderContract<T, Result>
query()
query<Result>(): DatabaseQueryBuilderContract<Result>;Get new query builder instance for select, update and delete calls
Type Parameters
| Type Parameter | Default type |
|---|---|
Result | any |
Returns
DatabaseQueryBuilderContract<Result>
raw()
raw(sql: string, bindings?: RawQueryBindings): RawBuilderContract;Returns instance of raw builder
Parameters
| Parameter | Type |
|---|---|
sql | string |
bindings? | RawQueryBindings |
Returns
RawBuilderContract
rawQuery()
rawQuery<Result>(sql: string, bindings?: RawQueryBindings): RawQueryBuilderContract<Result>;Get raw query builder instance
Type Parameters
| Type Parameter | Default type |
|---|---|
Result | any |
Parameters
| Parameter | Type |
|---|---|
sql | string |
bindings? | RawQueryBindings |
Returns
RawQueryBuilderContract<Result>
ref()
ref(reference: string): ReferenceBuilderContract;Returns instance of reference builder
Parameters
| Parameter | Type |
|---|---|
reference | string |
Returns
ReferenceBuilderContract
releaseAdvisoryLock()
releaseAdvisoryLock(key: string | number): Promise<boolean>;Parameters
| Parameter | Type |
|---|---|
key | string | number |
Returns
Promise<boolean>
truncate()
truncate(table: string, cascade?: boolean): Promise<void>;Truncate a given table
Parameters
| Parameter | Type |
|---|---|
table | string |
cascade? | boolean |
Returns
Promise<void>