@testjg/nativescript-sqlite
by testjg | v1.0.0
Add a plugin description
npm i --save @testjg/nativescript-sqlite

@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