npm i --save @testjg/nativescript-sqlite
- Version: 1.0.0
- GitHub: https://github.com/TestJG/mtmobile-plugins
- NPM: https://www.npmjs.com/package/%40testjg%2Fnativescript-sqlite
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
@testjg/nativescript-sqlite
Installation
ns plugin add @testjg/nativescript-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 "@testjg/nativescript-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]
)
);
});
License
Apache License Version 2.0