1 |
|
2 |
|
3 |
|
4 |
|
5 | import { Knex } from 'knex';
|
6 | import { EventEmitter } from 'events';
|
7 | import { EmitterContract } from '@ioc:Adonis/Core/Event';
|
8 | import { ProfilerRowContract } from '@ioc:Adonis/Core/Profiler';
|
9 | import { IsolationLevels, DialectContract, TransactionClientContract } from '@ioc:Adonis/Lucid/Database';
|
10 | import { RawBuilder } from '../Database/StaticBuilder/Raw';
|
11 | import { ReferenceBuilder } from '../Database/StaticBuilder/Reference';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export declare class TransactionClient extends EventEmitter implements TransactionClientContract {
|
17 | knexClient: Knex.Transaction;
|
18 | dialect: DialectContract;
|
19 | connectionName: string;
|
20 | debug: boolean;
|
21 | emitter: EmitterContract;
|
22 | |
23 |
|
24 |
|
25 | isTransaction: true;
|
26 | |
27 |
|
28 |
|
29 |
|
30 | mode: 'dual';
|
31 | |
32 |
|
33 |
|
34 | profiler?: ProfilerRowContract;
|
35 | private hooks;
|
36 | constructor(knexClient: Knex.Transaction, dialect: DialectContract, connectionName: string, debug: boolean, emitter: EmitterContract);
|
37 | /**
|
38 | * Whether or not transaction has been completed
|
39 | */
|
40 | get isCompleted(): boolean;
|
41 | /**
|
42 | * Returns schema instance for the write client
|
43 | */
|
44 | get schema(): Knex.SchemaBuilder;
|
45 | /**
|
46 | * Returns the read client. Which is just a single client in case
|
47 | * of transactions
|
48 | */
|
49 | getReadClient(): Knex.Transaction<any, any[]>;
|
50 | /**
|
51 | * Returns the write client. Which is just a single client in case
|
52 | * of transactions
|
53 | */
|
54 | getWriteClient(): Knex.Transaction<any, any[]>;
|
55 | /**
|
56 | * Truncate tables inside a transaction
|
57 | */
|
58 | truncate(table: string, cascade?: boolean): Promise<void>;
|
59 | /**
|
60 | * Returns an array of table names
|
61 | */
|
62 | getAllTables(schemas?: string[]): Promise<string[]>;
|
63 | /**
|
64 | * Get columns info inside a transaction. You won't need it here, however
|
65 | * added for API compatibility with the [[QueryClient]] class
|
66 | */
|
67 | columnsInfo(table: string, column?: string): Promise<any>;
|
68 | /**
|
69 | * Get a new query builder instance
|
70 | */
|
71 | knexQuery(): Knex.QueryBuilder;
|
72 | /**
|
73 | * Returns the knex raw query builder instance. The query builder is always
|
74 | * created from the `write` client, so before executing the query, you
|
75 | * may want to decide which client to use.
|
76 | */
|
77 | knexRawQuery(sql: string, bindings?: any): Knex.Raw;
|
78 | /**
|
79 | * Returns a query builder instance for a given model. The `connection`
|
80 | * and `profiler` is passed down to the model, so that it continue
|
81 | * using the same options
|
82 | */
|
83 | modelQuery(model: any): any;
|
84 | /**
|
85 | * Get a new query builder instance
|
86 | */
|
87 | query(): any;
|
88 | /**
|
89 | * Get a new insert query builder instance
|
90 | */
|
91 | insertQuery(): any;
|
92 | /**
|
93 | * Execute raw query on transaction
|
94 | */
|
95 | rawQuery(sql: any, bindings?: any): any;
|
96 | /**
|
97 | * Returns an instance of raw builder. This raw builder queries
|
98 | * cannot be executed. Use `rawQuery`, if you want to execute
|
99 | * queries raw queries.
|
100 | */
|
101 | raw(sql: string, bindings?: any): RawBuilder;
|
102 | /**
|
103 | * Returns reference builder.
|
104 | */
|
105 | ref(reference: string): ReferenceBuilder;
|
106 | /**
|
107 | * Returns another instance of transaction with save point
|
108 | */
|
109 | transaction(callback?: {
|
110 | isolationLevel?: IsolationLevels;
|
111 | } | ((trx: TransactionClientContract) => Promise<any>), options?: {
|
112 | isolationLevel?: IsolationLevels;
|
113 | }): Promise<any>;
|
114 | /**
|
115 | * Same as [[Transaction.query]] but also selects the table
|
116 | */
|
117 | from(table: any): any;
|
118 | /**
|
119 | * Same as [[Transaction.insertTable]] but also selects the table
|
120 | */
|
121 | table(table: any): any;
|
122 | /**
|
123 | * Register after commit or rollback hook
|
124 | */
|
125 | after(event: 'rollback' | 'commit', handler: () => void | Promise<void>): this;
|
126 | /**
|
127 | * Commit the transaction
|
128 | */
|
129 | commit(): Promise<void>;
|
130 | /**
|
131 | * Rollback the transaction
|
132 | */
|
133 | rollback(): Promise<void>;
|
134 | /**
|
135 | * Get advisory lock on the selected connection
|
136 | */
|
137 | getAdvisoryLock(key: string, timeout?: number): any;
|
138 | /**
|
139 | * Release advisory lock
|
140 | */
|
141 | releaseAdvisoryLock(key: string): any;
|
142 | }
|