-
Notifications
You must be signed in to change notification settings - Fork 1
/
executer.ts
58 lines (52 loc) · 2.28 KB
/
executer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { ParameterType, InsertResultType, SelectResultType, MutateResultType } from '../';
/**
* An Executer executes database queries.
*/
export interface Executer {
/**
* Execute a select query.
* @param query - The SQL to execute.
* @param params - An object containing query parameters for the query. Each
* parameter will be preceded with a colon in query.
* @return A promise that is resolved with an array of query rows. Each row
* should have key-value pairs, where the keys are the selected columns.
*/
select(query: string, params: ParameterType): Promise<SelectResultType>;
/**
* Execute an insert query.
* @param query - The SQL to execute.
* @param params - An object containing query parameters for the query. Each
* parameter will be preceded with a colon in query.
* @return A promise that will be resolved with an object describing the
* result of the insert. An insertId should be present on the object if
* available (e.g. if the insert inolved a generated column).
*/
insert(query: string, params: ParameterType): Promise<InsertResultType>;
/**
* Execute an update query.
* @param query - The SQL to execute.
* @param params - An object containing query parameters for the query. Each
* parameter will be preceded with a colon in query.
* @return An object that has an affectedRows property indicating the number
* of rows affected (changed) by the query.
*/
update(query: string, params: ParameterType): Promise<MutateResultType>;
/**
* Execute a delete query.
* @param query - The SQL to execute.
* @param params - An object containing query parameters for the query. Each
* parameter will be preceded with a colon in query.
* @return An object that has an affectedRows property indicating the number
* of rows affected (changed) by the query.
*/
delete(query: string, params: ParameterType): Promise<MutateResultType>;
/**
* Execute a raw query.
* @param query - The SQL to execute.
* @param params - An object containing query parameters for the query. Each
* parameter will be preceded with a colon in query.
* @return A promise that shall be resolved if the query succeeds, or
* rejected otherwise.
*/
query(query: string, params: ParameterType): Promise<any>;
}