npm i --save @herefishyfish/requery-sqlite
- 版本:3.4.2
- GitHub: https://github.com/herefishyfish/rxdb-nativescript
- NPM: https://npmjs.net.cn/package/%40herefishyfish%2Frequery-sqlite
- 下载
- 昨天: 0
- 上周: 1
- 上个月: 5
Nativescript: Requery Sqlite
由 @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]
)
);
});