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