@nativescript-community/sqlite
SQLite for Nativescript
npm i --save @nativescript-community/sqlite

@nativescript-community/sqlite

Downloads per month NPM Version

SQLite for Nativescript


目录

安装

从您的项目根目录运行以下命令

ns plugin add @nativescript-community/sqlite

使用方法

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

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

支持平台及 sqlite 版本