1 | import * as sqlite3 from 'sqlite3';
|
2 | import { Statement } from './Statement';
|
3 | export declare namespace ISqlite {
|
4 | interface SqlObj {
|
5 | sql: string;
|
6 | params?: any[];
|
7 | }
|
8 | interface SQLStatement {
|
9 | sql: string;
|
10 | values?: any[];
|
11 | }
|
12 | /**
|
13 | * Allows for input of a normal SQL string or
|
14 | * `sql-template-strings` object
|
15 | */
|
16 | type SqlType = SQLStatement | string;
|
17 | interface Config {
|
18 | /**
|
19 | * Valid values are filenames, ":memory:" for an anonymous in-memory
|
20 | * database and an empty string for an anonymous disk-based database.
|
21 | * Anonymous databases are not persisted and when closing the database
|
22 | * handle, their contents are lost.
|
23 | */
|
24 | filename: string;
|
25 | /**
|
26 | * One or more of sqlite3.OPEN_READONLY, sqlite3.OPEN_READWRITE and
|
27 | * sqlite3.OPEN_CREATE. The default value is OPEN_READWRITE | OPEN_CREATE.
|
28 | */
|
29 | mode?: number;
|
30 | /**
|
31 | * The database driver. Most will install `sqlite3` and use the `Database` class from it.
|
32 | * As long as the library you are using conforms to the `sqlite3` API, you can use it as
|
33 | * the driver.
|
34 | *
|
35 | * @example
|
36 | *
|
37 | * ```
|
38 | * import sqlite from 'sqlite3'
|
39 | *
|
40 | * const driver = sqlite.Database
|
41 | * ```
|
42 | */
|
43 | driver: any;
|
44 | }
|
45 | type ConfigureOption = 'trace' | 'profile' | 'busyTimeout';
|
46 | interface RunResult<Stmt extends sqlite3.Statement = sqlite3.Statement> {
|
47 | /**
|
48 | * Statement object.
|
49 | *
|
50 | * It is not possible to run the statement again because it is
|
51 | * automatically finalized after running for the first time.
|
52 | * Any subsequent attempts to run the statement again will fail.
|
53 | */
|
54 | stmt: Statement<Stmt>;
|
55 | /**
|
56 | * Row id of the inserted row.
|
57 | *
|
58 | * Only contains valid information when the query was a successfully
|
59 | * completed INSERT statement.
|
60 | */
|
61 | lastID?: number;
|
62 | /**
|
63 | * Number of rows changed.
|
64 | *
|
65 | * Only contains valid information when the query was a
|
66 | * successfully completed UPDATE or DELETE statement.
|
67 | */
|
68 | changes?: number;
|
69 | }
|
70 | }
|
71 | export declare namespace IMigrate {
|
72 | interface MigrationParams {
|
73 | /**
|
74 | * If true, will force the migration API to rollback and re-apply the latest migration over
|
75 | * again each time when Node.js app launches.
|
76 | */
|
77 | force?: boolean;
|
78 | /**
|
79 | * Migrations table name. Default is 'migrations'
|
80 | */
|
81 | table?: string;
|
82 | /**
|
83 | * Path to the migrations folder. Default is `path.join(process.cwd(), 'migrations')`
|
84 | */
|
85 | migrationsPath?: string;
|
86 | /**
|
87 | * Migration data read from migrations folder. `migrationsPath` will be ignored if this is
|
88 | * provided.
|
89 | */
|
90 | migrations?: readonly MigrationData[];
|
91 | }
|
92 | interface MigrationFile {
|
93 | id: number;
|
94 | name: string;
|
95 | filename: string;
|
96 | }
|
97 | interface MigrationData {
|
98 | id: number;
|
99 | name: string;
|
100 | up: string;
|
101 | down: string;
|
102 | }
|
103 | }
|