mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
fix(storage): bad defaults in options. Fixes #647
This commit is contained in:
@ -22,7 +22,7 @@ const DB_NAME = '__ionicstorage';
|
|||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* // Sql storage also exposes the full engine underneath
|
* // Sql storage also exposes the full engine underneath
|
||||||
* storage.query('insert into projects(name, data) values('Cool Project', 'blah');'
|
* storage.query('insert into projects(name, data) values('Cool Project', 'blah')');
|
||||||
* storage.query('select * from projects').then((resp) => {})
|
* storage.query('select * from projects').then((resp) => {})
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@ export class SqlStorage extends StorageEngine {
|
|||||||
static BACKUP_LIBRARY = 1
|
static BACKUP_LIBRARY = 1
|
||||||
static BACKUP_DOCUMENTS = 0
|
static BACKUP_DOCUMENTS = 0
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options={}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
let dbOptions = util.defaults(options, {
|
let dbOptions = util.defaults(options, {
|
||||||
@ -98,19 +98,25 @@ export class SqlStorage extends StorageEngine {
|
|||||||
*/
|
*/
|
||||||
query(query, ...params) {
|
query(query, ...params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._db.transaction((tx) => {
|
try {
|
||||||
tx.executeSql(query, params, (tx, res) => {
|
this._db.transaction((tx) => {
|
||||||
resolve({
|
tx.executeSql(query, params, (tx, res) => {
|
||||||
tx: tx,
|
resolve({
|
||||||
res: res
|
tx: tx,
|
||||||
});
|
res: res
|
||||||
}, (tx, err) => {
|
});
|
||||||
reject({
|
}, (tx, err) => {
|
||||||
tx: tx,
|
reject({
|
||||||
err: err
|
tx: tx,
|
||||||
});
|
err: err
|
||||||
})
|
});
|
||||||
});
|
})
|
||||||
|
}, err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user