npm i --save @akylas/nativescript-sqlite
- 版本:3.3.12
- GitHub:
- NPM: https://npmjs.net.cn/package/%40akylas%2Fnativescript-sqlite
- 下载
- 昨天: 14
- 上周: 29
- 上个月: 62
Nativescript: Akylas Sqlite
安装
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]
)
);
});