是否有任何js通过Trigger.io访问设备(ios和android)sqlite数据库的示例?
答案 0 :(得分:2)
可以使用普通的网络数据库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);
});
});
答案 1 :(得分:0)
现在你应该使用类似LocalForage之类的东西,通过indexedDB回溯到webSQL到localStorage,并为你提供一致的api。如果您使用的是Angular / Ionic,那么这就是业务:Angular-LocalForage