Open fdjean opened 9 years ago
Hi, thank you a lot for contribution
Agree on adding callback for device or document ready.
However in future releases I'm planning to remove angular dependency and make library stand alone. For angular there will be a plugin.
Anyway, I will add something for this in next release. Also if u want to send some improvements in PR will appreciate
I'm not comfortable with Git and Github, so I publish here for now ;)
Tested OK for websql desktop (chrome), websql & sqlite mobile (android cordova plugin sqlcipher) https://github.com/litehelpers/Cordova-sqlcipher-adapter
For SQLite mobile:
.factory('wSQL', function (W_SQL_CONFIG, $q) {
TO
.factory('wSQL', function (W_SQL_CONFIG, $q, $ionicPlatform, $cordovaSQLite) {
And
var Db = (function () {
var db, db_set = false;
return {
get: function () {
return db;
},
set: function (db_params) {
db = window.openDatabase(db_params.name, db_params.version, db_params.sub_name, db_params.size);
db_set = true;
return db;
}
}
}
TO
var Db = (function () {
var db = false;
return {
get: function () {
return db;
},
set: function (db_params) {
if (window.cordova) {
$ionicPlatform.ready(function () {
db = $cordovaSQLite.openDB(db_params);
// websql mobile
// db = window.openDatabase(db_params.name, db_params.version, db_params.sub_name, db_params.size);
});
} else {
db = window.openDatabase(db_params.name, db_params.version, db_params.sub_name, db_params.size);
}
return db;
}
}
}
To have multiple insertions with the same order as array:
InsertQuery.prototype.batch_insert_query = function(table, data, ignore){
...
sql += ' UNION SELECT '+row_sql.query;
...
};
To
InsertQuery.prototype.batch_insert_query = function(table, data, ignore){
...
sql += ' UNION ALL SELECT '+row_sql.query;
...
};
Right, good suggestion. However this means that library will require ionic as dependency.
Do u think it will work the same fine if using just device.ready instead of $ionicPlatform.ready ?
Hey this plugin is not working with the below mentioned code in android app.
var Db = (function () { var db = false; return { get: function () { return db; }, set: function (db_params) { if (window.cordova) { $ionicPlatform.ready(function () { db = $cordovaSQLite.openDB(db_params); // websql mobile // db = window.openDatabase(db_params.name, db_params.version, db_params.sub_name, db_params.size); }); } else { db = window.openDatabase(db_params.name, db_params.version, db_params.sub_name, db_params.size); } return db; } }
To use with websql or sqlite (ionic, cordova plugin) line 88:
To (not fully tested):
Passing a open params (object) I can use https://github.com/litehelpers/Cordova-sqlcipher-adapter with customs options
And to finish :smirk: line 82:
db_set is a dead variable ?