ionic新增cordova外掛-SQLite
阿新 • • 發佈:2019-02-16
SQLite
呼叫SQLite本地資料庫儲存介面
cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage.git
Example
module.controller('MyCtrl', function($scope, $cordovaSQLite) {
var db = $cordovaSQLite.openDB({ name: "my.db" });
// for opening a background db:
var db = $cordovaSQLite.openDB({ name: "my.db" , bgType: 1 });
$scope.execute = function() {
var query = "INSERT INTO test_table (data, data_num) VALUES (?,?)";
$cordovaSQLite.execute(db, query, ["test", 100]).then(function(res) {
console.log("insertId: " + res.insertId);
}, function (err) {
console.error(err);
});
};
});