UNPKG

7.16 kBTypeScriptView Raw
1// Type definitions for sqlite3
2// Project: http://github.com/tryghost/node-sqlite3
3
4/// <reference types="node" />
5
6import events = require("events");
7
8export const OPEN_READONLY: number;
9export const OPEN_READWRITE: number;
10export const OPEN_CREATE: number;
11export const OPEN_FULLMUTEX: number;
12export const OPEN_SHAREDCACHE: number;
13export const OPEN_PRIVATECACHE: number;
14export const OPEN_URI: number;
15
16export const VERSION: string;
17export const SOURCE_ID: string;
18export const VERSION_NUMBER: number;
19
20export const OK: number;
21export const ERROR: number;
22export const INTERNAL: number;
23export const PERM: number;
24export const ABORT: number;
25export const BUSY: number;
26export const LOCKED: number;
27export const NOMEM: number;
28export const READONLY: number;
29export const INTERRUPT: number
30export const IOERR: number;
31export const CORRUPT: number
32export const NOTFOUND: number;
33export const FULL: number;
34export const CANTOPEN: number;
35export const PROTOCOL: number;
36export const EMPTY: number;
37export const SCHEMA: number;
38export const TOOBIG: number
39export const CONSTRAINT: number
40export const MISMATCH: number;
41export const MISUSE: number;
42export const NOLFS: number;
43export const AUTH: number
44export const FORMAT: number;
45export const RANGE: number
46export const NOTADB: number;
47
48export const LIMIT_LENGTH: number;
49export const LIMIT_SQL_LENGTH: number;
50export const LIMIT_COLUMN: number;
51export const LIMIT_EXPR_DEPTH: number;
52export const LIMIT_COMPOUND_SELECT: number;
53export const LIMIT_VDBE_OP: number;
54export const LIMIT_FUNCTION_ARG: number;
55export const LIMIT_ATTACHED: number;
56export const LIMIT_LIKE_PATTERN_LENGTH: number;
57export const LIMIT_VARIABLE_NUMBER: number;
58export const LIMIT_TRIGGER_DEPTH: number;
59export const LIMIT_WORKER_THREADS: number;
60
61export const cached: {
62 Database(filename: string, callback?: (this: Database, err: Error | null) => void): Database;
63 Database(filename: string, mode?: number, callback?: (this: Database, err: Error | null) => void): Database;
64};
65
66export interface RunResult extends Statement {
67 lastID: number;
68 changes: number;
69}
70
71export class Statement extends events.EventEmitter {
72 bind(callback?: (err: Error | null) => void): this;
73 bind(...params: any[]): this;
74
75 reset(callback?: (err: null) => void): this;
76
77 finalize(callback?: (err: Error) => void): Database;
78
79 run(callback?: (err: Error | null) => void): this;
80 run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
81 run(...params: any[]): this;
82
83 get<T>(callback?: (err: Error | null, row?: T) => void): this;
84 get<T>(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this;
85 get(...params: any[]): this;
86
87 all<T>(callback?: (err: Error | null, rows: T[]) => void): this;
88 all<T>(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this;
89 all(...params: any[]): this;
90
91 each<T>(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
92 each<T>(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
93 each(...params: any[]): this;
94}
95
96export class Database extends events.EventEmitter {
97 constructor(filename: string, callback?: (err: Error | null) => void);
98 constructor(filename: string, mode?: number, callback?: (err: Error | null) => void);
99
100 close(callback?: (err: Error | null) => void): void;
101
102 run(sql: string, callback?: (this: RunResult, err: Error | null) => void): this;
103 run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
104 run(sql: string, ...params: any[]): this;
105
106 get<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this;
107 get<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this;
108 get(sql: string, ...params: any[]): this;
109
110 all<T>(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
111 all<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
112 all(sql: string, ...params: any[]): this;
113
114 each<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
115 each<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
116 each(sql: string, ...params: any[]): this;
117
118 exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;
119
120 prepare(sql: string, callback?: (this: Statement, err: Error | null) => void): Statement;
121 prepare(sql: string, params: any, callback?: (this: Statement, err: Error | null) => void): Statement;
122 prepare(sql: string, ...params: any[]): Statement;
123
124 serialize(callback?: () => void): void;
125 parallelize(callback?: () => void): void;
126
127 on(event: "trace", listener: (sql: string) => void): this;
128 on(event: "profile", listener: (sql: string, time: number) => void): this;
129 on(event: "change", listener: (type: string, database: string, table: string, rowid: number) => void): this;
130 on(event: "error", listener: (err: Error) => void): this;
131 on(event: "open" | "close", listener: () => void): this;
132 on(event: string, listener: (...args: any[]) => void): this;
133
134 configure(option: "busyTimeout", value: number): void;
135 configure(option: "limit", id: number, value: number): void;
136
137 loadExtension(filename: string, callback?: (err: Error | null) => void): this;
138
139 wait(callback?: (param: null) => void): this;
140
141 interrupt(): void;
142}
143
144export function verbose(): sqlite3;
145
146export interface sqlite3 {
147 OPEN_READONLY: number;
148 OPEN_READWRITE: number;
149 OPEN_CREATE: number;
150 OPEN_FULLMUTEX: number;
151 OPEN_SHAREDCACHE: number;
152 OPEN_PRIVATECACHE: number;
153 OPEN_URI: number;
154
155 VERSION: string;
156 SOURCE_ID: string;
157 VERSION_NUMBER: number;
158
159 OK: number;
160 ERROR: number;
161 INTERNAL: number;
162 PERM: number;
163 ABORT: number;
164 BUSY: number;
165 LOCKED: number;
166 NOMEM: number;
167 READONLY: number;
168 INTERRUPT: number
169 IOERR: number;
170 CORRUPT: number
171 NOTFOUND: number;
172 FULL: number;
173 CANTOPEN: number;
174 PROTOCOL: number;
175 EMPTY: number;
176 SCHEMA: number;
177 TOOBIG: number
178 CONSTRAINT: number
179 MISMATCH: number;
180 MISUSE: number;
181 NOLFS: number;
182 AUTH: number
183 FORMAT: number;
184 RANGE: number
185 NOTADB: number;
186
187 LIMIT_LENGTH: number;
188 LIMIT_SQL_LENGTH: number;
189 LIMIT_COLUMN: number;
190 LIMIT_EXPR_DEPTH: number;
191 LIMIT_COMPOUND_SELECT: number;
192 LIMIT_VDBE_OP: number;
193 LIMIT_FUNCTION_ARG: number;
194 LIMIT_ATTACHED: number;
195 LIMIT_LIKE_PATTERN_LENGTH: number;
196 LIMIT_VARIABLE_NUMBER: number;
197 LIMIT_TRIGGER_DEPTH: number;
198 LIMIT_WORKER_THREADS: number;
199
200 cached: typeof cached;
201 RunResult: RunResult;
202 Statement: typeof Statement;
203 Database: typeof Database;
204 verbose(): this;
205}
\No newline at end of file