1 |
|
2 |
|
3 |
|
4 | import { Knex } from 'knex';
|
5 | import { EmitterContract } from '@ioc:Adonis/Core/Event';
|
6 | import { ProfilerRowContract, ProfilerContract } from '@ioc:Adonis/Core/Profiler';
|
7 | import { IsolationLevels, DialectContract, ConnectionContract, QueryClientContract, TransactionClientContract } from '@ioc:Adonis/Lucid/Database';
|
8 | import { RawBuilder } from '../Database/StaticBuilder/Raw';
|
9 | import { ReferenceBuilder } from '../Database/StaticBuilder/Reference';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare class QueryClient implements QueryClientContract {
|
15 | readonly mode: 'dual' | 'write' | 'read';
|
16 | private connection;
|
17 | emitter: EmitterContract;
|
18 | |
19 |
|
20 |
|
21 | readonly isTransaction = false;
|
22 | |
23 |
|
24 |
|
25 | dialect: DialectContract;
|
26 | |
27 |
|
28 |
|
29 | profiler?: ProfilerRowContract | ProfilerContract;
|
30 | |
31 |
|
32 |
|
33 | readonly connectionName: string;
|
34 | |
35 |
|
36 |
|
37 | debug: boolean;
|
38 | constructor(mode: 'dual' | 'write' | 'read', connection: ConnectionContract, emitter: EmitterContract);
|
39 | /**
|
40 | * Returns schema instance for the write client
|
41 | */
|
42 | get schema(): Knex.SchemaBuilder;
|
43 | /**
|
44 | * Returns the read client. The readClient is optional, since we can get
|
45 | * an instance of [[QueryClient]] with a sticky write client.
|
46 | */
|
47 | getReadClient(): Knex;
|
48 | /**
|
49 | * Returns the write client
|
50 | */
|
51 | getWriteClient(): Knex;
|
52 | /**
|
53 | * Truncate table
|
54 | */
|
55 | truncate(table: string, cascade?: boolean): Promise<void>;
|
56 | /**
|
57 | * Get information for a table columns
|
58 | */
|
59 | columnsInfo(table: string, column?: string): Promise<any>;
|
60 | /**
|
61 | * Returns an array of table names
|
62 | */
|
63 | getAllTables(schemas?: string[]): Promise<string[]>;
|
64 | /**
|
65 | * Returns an instance of a transaction. Each transaction will
|
66 | * query and hold a single connection for all queries.
|
67 | */
|
68 | transaction(callback?: {
|
69 | isolationLevel?: IsolationLevels;
|
70 | } | ((trx: TransactionClientContract) => Promise<any>), options?: {
|
71 | isolationLevel?: IsolationLevels;
|
72 | }): Promise<any>;
|
73 | /**
|
74 | * Returns the knex query builder instance. The query builder is always
|
75 | * created from the `write` client, so before executing the query, you
|
76 | * may want to decide which client to use.
|
77 | */
|
78 | knexQuery(): Knex.QueryBuilder;
|
79 | /**
|
80 | * Returns the knex raw query builder instance. The query builder is always
|
81 | * created from the `write` client, so before executing the query, you
|
82 | * may want to decide which client to use.
|
83 | */
|
84 | knexRawQuery(sql: string, bindings?: any): Knex.Raw;
|
85 | /**
|
86 | * Returns a query builder instance for a given model.
|
87 | */
|
88 | modelQuery(model: any): any;
|
89 | /**
|
90 | * Returns instance of a query builder for selecting, updating
|
91 | * or deleting rows
|
92 | */
|
93 | query(): any;
|
94 | /**
|
95 | * Returns instance of a query builder for inserting rows
|
96 | */
|
97 | insertQuery(): any;
|
98 | /**
|
99 | * Returns instance of raw query builder
|
100 | */
|
101 | rawQuery(sql: any, bindings?: any): any;
|
102 | /**
|
103 | * Returns an instance of raw builder. This raw builder queries
|
104 | * cannot be executed. Use `rawQuery`, if you want to execute
|
105 | * queries raw queries.
|
106 | */
|
107 | raw(sql: string, bindings?: any): RawBuilder;
|
108 | /**
|
109 | * Returns reference builder.
|
110 | */
|
111 | ref(reference: string): ReferenceBuilder;
|
112 | /**
|
113 | * Returns instance of a query builder and selects the table
|
114 | */
|
115 | from(table: any): any;
|
116 | /**
|
117 | * Returns instance of a query builder and selects the table
|
118 | * for an insert query
|
119 | */
|
120 | table(table: any): any;
|
121 | /**
|
122 | * Get advisory lock on the selected connection
|
123 | */
|
124 | getAdvisoryLock(key: string, timeout?: number): any;
|
125 | /**
|
126 | * Release advisory lock
|
127 | */
|
128 | releaseAdvisoryLock(key: string): any;
|
129 | }
|