npm i --save @testjg/nativescript-sqlite
- 版本:1.0.0
- GitHub: https://github.com/TestJG/mtmobile-plugins
- NPM: https://npmjs.net.cn/package/%40testjg%2Fnativescript-sqlite
- 下载次数
- 昨日: 0
- 上周: 0
- 上月: 0
@testjg/nativescript-sqlite
安装
ns plugin add @testjg/nativescript-sqlite
使用
您应该注意将 sqlite 调用包装到您首选的异步选项(promises、observables、async/await)。并捕获抛出的任何异常。
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]
)
);
});
许可证
Apache 许可协议第 2 版