-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
65 lines (64 loc) · 1.94 KB
/
types.d.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
58
59
60
61
62
63
64
65
export interface Req {
/** The SQL query string as a Named Placeholer
* @example SELECT * FROM users WHERE id = :id
* @example INSERT INTO users (name, email) VALUES (:name, :email)
* @example UPDATE users SET name = :name, email = :email WHERE id = :id
* @example DELETE FROM users WHERE id = :id
*/
sql: string;
/** Is this a read write query?
* @default false
*/
isWrite: boolean;
/** Options are 'rqlite' | 'mysql'
* @default 'mysql'
*/
db: "mysql" | "rqlite";
/** Queue (optional) https://github.com/rqlite/rqlite/blob/master/DOC/QUEUED_WRITES.md */
queue?: boolean;
/** Values to be inserted into the query
* @example {id: 1}
* @example {name: 'John', email: 'sam@gmail.com'}
*/
values: { [param: string]: string | number };
}
export interface Res {
/**
* The request object containing the SQL query string and values
* @type {Interface}
* @property {string} sql The SQL query string
* @property {boolean} isWrite Is this a read write query?
* @property {string} db Options are 'rqlite' | 'mysql'
* @property {boolean} queue Queue (optional)
* @property {object} values Values to be inserted into the query
* @example
* { sql: 'SELECT * FROM users WHERE id = :id', isWrite: false, db: 'mysql', queue: false, values: { id: 1 } }
*/
req: Req,
/** The result of a SELECT query in an array of objects
* @type {Array}
* @example
* [ { id: 1, name: 'John' }, { id: 2, name: 'Jane' } ]
*/
rows: { [param: string]: string | number }[],
/** The number of rows affected by the query
* @type {number}
* @default 0
*/
affectedRows: number,
/** The insert ID of the last row inserted
* @type {number}
* @default 0
*/
insertId: number,
/** The time it took to execute the query (only available for rqlite)
* @type {number}
* @default 0
*/
time: number,
/** The error if there was one
* @type {string}
* @default ''
*/
error: string
}