jorged
September 14, 2016, 7:36am
1
Hi,
I’m developing an ionic 2 app, i need to create a local database, i’m usin sqlite they allways return an error object.
Here is my code, thanks in advance to anyone who can help:
this.storage = new Storage(SqlStorage, {name:‘tfc’});
this.storage.query(‘insert into logins(name, password) values("’+ data.user +’", “’+ data.password +’”)’)
.then(res => alert(‘resultado:’ + res))
.catch(error => alert(‘error:’ + error))
See if below link is useful, I followed this tutorial to implement SqlStorage
Also, there are getter and setter which are also useful, if you like source code, below is source code of SqlStorage
import { StorageEngine } from './storage';
import { defaults, assign } from '../util/util';
const DB_NAME: string = '__ionicstorage';
const win: any = window;
/**
* SqlStorage is a wrapper that uses SQLite when running natively (if available)
* to store data in a persistent SQL store on the filesystem
* or uses WebSQL when serving the app to the browser.
*
* This is the preferred storage engine, as data will be stored in appropriate
* app storage, unlike Local Storage which is treated differently by the OS.
*
* For convenience, the engine supports key/value storage for simple get/set and blob
* storage. The full SQL engine is exposed underneath through the `query` method.
*
* @usage
```js
This file has been truncated. show original
1 Like