原生SQLite
Nativescript的SQLite
npm i --save nativescript-akylas-sqlite

原生应用商店:Akylas Sqlite

Build Status npm version

安装

tns plugin add nativescript-akylas-sqlite

使用

您应该注意将sqlite调用包装到您首选的异步选项(promises、observables、async/await)中。并且捕获抛出的任何异常。

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]
)
);
});