@herefishyfish/requery-sqlite
SQLite for Nativescript
npm i --save @herefishyfish/requery-sqlite

Nativescript: Requery Sqlite

npm npm

由 @nativescript-community/sqlite 包的分支,使用支持现代 Android SQLite 特性的 requery SQLite 实现。

安装

npm i @herefishyfish/requery-sqlite

用法

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

import { openOrCreate, deleteDatabase } from "@herefishyfish/requery-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]
)
);
});