I got an error with the $cordovaSQLite:
Error: ‘undefined’ is not a function (evaluating ‘e.transaction(function(n){n.executeSql(o,r,function(n,e){q.resolve(e)},function(n,e){q.reject(e)})})’) at ionic.bundle.js:18897
and in sequence the console gives:
execute@file:///myPath/myApp.app/www/js/ng-cordova.min.js:1:14061
here the code in my controller:
$scope.dbTest = function(){
var db = 'testing';
var query = '';
$cordovaSQLite.openDB(db);
query = 'CREATE TABLE IF NOT EXISTS MyTable (id INTEGER PRIMARY KEY ASC, text_sample TEXT, date_sample DATE)';
$cordovaSQLite.execute(db, query, [])
.then(function(data){
console.log(data);
});
query = 'INSERT INTO MyTable(text_sample, date_sample) VALUES ("Test insertion","2014-05-28")';
$cordovaSQLite.execute(db, query, [])
.then(function(data){
console.log(data);
});
query = 'SELECT * FROM MyTable ORDER BY id';
$cordovaSQLite.execute(db, query, [])
.then(function(data){
console.log(data);
});
}
anyone have success with the SQLite plugin + ngCordova? if yes, could help me? or fix some mistake in my code…
I’m using the last launch: 1.0.0-beta.9 Gadolinium Gator (2014-07-02)
testing in iOS simulator and device… the DB is opened, but I can’t run the
$cordovaSQLite.execute(db, query, binding) function…
query = 'SELECT * FROM MyTable ORDER BY id';
$cordovaSQLite.execute(db, query, [])
.then(function(data){
for (var i = 0; i < data.rows.length; i++) {
$scope.result = data.rows.item(i);
console.log($scope.result);
}
});
Hi @fleajump and @fdedeh, thanks for all your help! Would you know if there is any way to open a prepopulated SQLite DB? One which is already present as a file, suppose test.db in the /www/ folder?
Thanks so much!
@shubs, I read a tutorial some time ago where the author explains that to open a prepopulated DB in SQLite you need just insert the .db file in your project and specify the full path to it when you open the DB… something like
var dbName = 'your/path/testing.db';
I searched for this tutorial again but unfortunately I can’t find it…