I implemented the remove method in the ItemDataSource section of the SQLite3.js file. The method so far works fine. The only problem I have is that I provide the ItemDataSource constructor with the SQL selecting the specified data form a table, e.g. "SELECT
* FROM perscomp". In the remove method I need the table name for removing a record from the table. I implemented this with a reg expression for getting the last word in the sql statement. This is fine for the current listview but as soon as the SQL changes
(e.g. having a WHERE clause) it will not work anymore.
How can I pass a table name to the ItemDataSource constructor or even better to the remove method?
Following is the code for the remove method:
remove: function (key, indexHint) {
var that = this;
var table = that._sql.toString().replace(/[\s-]+$/,'').split(/[\s-]/).pop();
return db.runAsync('DELETE FROM ' + table + ' WHERE ' + keyColumnName + '=' + key)
.then(function () {
return new WinJS.Promise.wrap(null);
})
},