npm i --save nativeScript-mtmobile-sqlite
- 版本:1.3.0
- GitHub: https://github.com/TestJG/nativescript-mtmobile-sqlite
- NPM: https://npmjs.net.cn/package/nativescript-mtmobile-sqlite
- 下载次数
- 昨天: 0
- 上周: 4
- 上个月: 22
Nativescript: MtMobile Sqlite
安装
tns plugin add nativescript-mtmobile-sqlite
使用
你应该注意将 sqlite 调用包装到你喜欢的异步选项(promises、observables、async/await)中。并捕获抛出的任何异常。
import { openOrCreate, deleteDatabase } from "nativescript-mtmobile-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]
)
);
});