是否有任何 js 通过 Trigger.io 访问设备(ios 和 android)sqlite 数据库的示例?
最佳答案
普通网络数据库 API 可用:http://www.w3.org/TR/webdatabase/
注意:并非所有浏览器都支持 Web SQL http://caniuse.com/#feat=sql-storage
例如,我们运行的其中一个测试与此类似:
var db = openDatabase('mydb', '1.0', 'example database', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")');
});
db.transaction(function (tx) {
tx.executeSql('DROP TABLE foo');
// known to fail - so should rollback the DROP statement
tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")');
forge.logging.error("INSERT into non-existent table succeeded!");
}, function (err) {
forge.logging.info("error callback invoked, as expected");
});
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM foo', [], function (tx, results) {
forge.logging.info("row: "+results);
});
});
关于javascript - Tigger.io 访问设备 sqlite 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10509075/