npm i --save nativescript-akylas-sqlite
- Version: 3.0.5
- GitHub:
- NPM: https://www.npmjs.com/package/nativescript-akylas-sqlite
- Downloads:
- Last Day: 1
- Last Week: 2
- Last Month: 7
Nativescript: Akylas Sqlite
Installation
tns plugin add nativescript-akylas-sqlite
Usage
You should take care of wrapping sqlite calls to your preferred async option (promises, observables, async/await). And catch any exceptions thrown.
import { openOrCreate, deleteDatabase } from "nativescript-akylas-sqlite";
const sqlite = openOrCreate("path/to/db");
sqlite.execute("CREATE TABLE names (id INT, name TEXT)");
sqlite.transaction(cancelTransaction => {
// Calling cancelTransaction will rollback all changes made to db
names.forEach((name, id) =>
sqlite.execute(
"INSERT INTO names (id, name) VALUES (?, ?)",
[id, name]
)
);
});