@testjg/nativescript-sqlite
v1.0.0
Published
Add a plugin description
Downloads
3
Maintainers
Readme
@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