1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | export interface SQLiteDatabaseConfig {
|
3 | /**
|
4 | * Name of the database. Example: 'my.db'
|
5 | */
|
6 | name: string;
|
7 | /**
|
8 | * Location of the database. Example: 'default'
|
9 | */
|
10 | location?: string;
|
11 | /**
|
12 | * iOS Database Location. Example: 'Library'
|
13 | */
|
14 | iosDatabaseLocation?: string;
|
15 | /**
|
16 | * support arbitrary database location on android with https://github.com/litehelpers/cordova-sqlite-evcore-extbuild-free
|
17 | */
|
18 | androidDatabaseLocation?: string;
|
19 | /**
|
20 | * support opening pre-filled databases with https://github.com/litehelpers/cordova-sqlite-ext
|
21 | */
|
22 | createFromLocation?: number;
|
23 | /**
|
24 | * support encrypted databases with https://github.com/litehelpers/Cordova-sqlcipher-adapter
|
25 | */
|
26 | key?: string;
|
27 | }
|
28 | /**
|
29 | * @hidden
|
30 | */
|
31 | export interface DbTransaction {
|
32 | executeSql: (sql: any, values?: any[], success?: Function, error?: Function) => void;
|
33 | }
|
34 | /**
|
35 | * @hidden
|
36 | */
|
37 | export interface SQLiteTransaction extends DbTransaction {
|
38 | start: () => void;
|
39 | addStatement: DbTransaction['executeSql'];
|
40 | handleStatementSuccess: (handler: Function, response: any) => void;
|
41 | handleStatementFailure: (handler: Function, response: any) => void;
|
42 | run: () => void;
|
43 | abort: (txFailure: any) => void;
|
44 | finish: () => void;
|
45 | abortFromQ: (sqlerror: any) => void;
|
46 | }
|
47 | /**
|
48 | * @hidden
|
49 | */
|
50 | export declare class SQLiteObject {
|
51 | _objectInstance: any;
|
52 | constructor(_objectInstance: any);
|
53 | databaseFeatures: {
|
54 | isSQLitePluginDatabase: boolean;
|
55 | };
|
56 | openDBs: any;
|
57 | addTransaction(transaction: (tx: SQLiteTransaction) => void): void;
|
58 | /**
|
59 | * @param fn {Function}
|
60 | * @returns {Promise<any>}
|
61 | */
|
62 | transaction(fn: (tx: DbTransaction) => void): Promise<any>;
|
63 | /**
|
64 | * @param fn {Function}
|
65 | * @returns {Promise<any>}
|
66 | */
|
67 | readTransaction(fn: (tx: SQLiteTransaction) => void): Promise<any>;
|
68 | startNextTransaction(): void;
|
69 | /**
|
70 | * @returns {Promise<any>}
|
71 | */
|
72 | open(): Promise<any>;
|
73 | /**
|
74 | * @returns {Promise<any>}
|
75 | */
|
76 | close(): Promise<any>;
|
77 | /**
|
78 | * Execute SQL on the opened database. Note, you must call `create` first, and
|
79 | * ensure it resolved and successfully opened the database.
|
80 | */
|
81 | executeSql(statement: string, params?: any[]): Promise<any>;
|
82 | /**
|
83 | * @param sqlStatements {string[] | string[][] | any[]}
|
84 | * @returns {Promise<any>}
|
85 | */
|
86 | sqlBatch(sqlStatements: (string | string[] | any)[]): Promise<any>;
|
87 | abortallPendingTransactions(): void;
|
88 | }
|
89 | /**
|
90 | * @name SQLite
|
91 | *
|
92 | * @description
|
93 | * Access SQLite databases on the device.
|
94 | *
|
95 | * @usage
|
96 | *
|
97 | * ```typescript
|
98 | * import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
|
99 | *
|
100 | * constructor(private sqlite: SQLite) { }
|
101 | *
|
102 | * ...
|
103 | *
|
104 | * this.sqlite.create({
|
105 | * name: 'data.db',
|
106 | * location: 'default'
|
107 | * })
|
108 | * .then((db: SQLiteObject) => {
|
109 | *
|
110 | *
|
111 | * db.executeSql('create table danceMoves(name VARCHAR(32))', [])
|
112 | * .then(() => console.log('Executed SQL'))
|
113 | * .catch(e => console.log(e));
|
114 | *
|
115 | *
|
116 | * })
|
117 | * .catch(e => console.log(e));
|
118 | *
|
119 | * ```
|
120 | *
|
121 | * @classes
|
122 | * SQLiteObject
|
123 | * @interfaces
|
124 | * SQLiteDatabaseConfig
|
125 | * SQLiteTransaction
|
126 | */
|
127 | export declare class SQLiteOriginal extends IonicNativePlugin {
|
128 | /**
|
129 | * Open or create a SQLite database file.
|
130 | *
|
131 | * See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database
|
132 | *
|
133 | * @param config {SQLiteDatabaseConfig} database configuration
|
134 | * @return Promise<SQLiteObject>
|
135 | */
|
136 | create(config: SQLiteDatabaseConfig): Promise<SQLiteObject>;
|
137 | /**
|
138 | * Verify that both the Javascript and native part of this plugin are installed in your application
|
139 | * @returns {Promise<any>}
|
140 | */
|
141 | echoTest(): Promise<any>;
|
142 | /**
|
143 | * Automatically verify basic database access operations including opening a database
|
144 | * @returns {Promise<any>}
|
145 | */
|
146 | selfTest(): Promise<any>;
|
147 | /**
|
148 | * Deletes a database
|
149 | * @param config {SQLiteDatabaseConfig} database configuration
|
150 | * @returns {Promise<any>}
|
151 | */
|
152 | deleteDatabase(config: SQLiteDatabaseConfig): Promise<any>;
|
153 | }
|
154 |
|
155 | export declare const SQLite: SQLiteOriginal; |
\ | No newline at end of file |