npm i --save nativescript-mtmobile-sqlite
- Version: 1.3.0
- GitHub: https://github.com/TestJG/nativescript-mtmobile-sqlite
- NPM: https://www.npmjs.com/package/nativescript-mtmobile-sqlite
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
Nativescript: MtMobile Sqlite
Installation
tns plugin add nativescript-mtmobile-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-mtmobile-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]
)
);
});