Hello! In service ProjectListDB_ProjectList_list_service you map $ to CreateSQLiteProjects localStorage variable and add in mapping code to fill in SQLite table in DB. Put console.log(value); in the beginning of code. In console you most likely see something like pre[Object, Object, Object]/pre
So you can't call retrieved data the way you do prevalue.id, value.ProjectID, value.ProjectTitle, value.createdAt, value.updatedAt/pre because you retrieve not object, but array. Try to use the following code in mapping:
prefunction doRequest(tx, value) {
tx.executeSql('SELECT * FROM "TableProjectList" WHERE "objectId" = "' + value.id + '"', [], function(tx, results) {
//console.log('rows :' + results.rows.length);
if (results.rows.length == 0) {
//console.log('Go and add table ' + value.number);
tx.executeSql('INSERT INTO "TableProjectList" (objectId, ProjectID, ProjectTitle, _createdAt, updatedAt) values (?, ?, ?, ?, ?)', [value.id, value.ProjectID, value.ProjectTitle, value.createdAt, value.updatedAt]);
}
});
}
function onError() {
console.log('some errors');
}
function onSuccess() {
console.log('all fine');
}
function populateDB(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS "TableProjectList"(_objectId TEXT, ProjectID TEXT, ProjectTitle TEXT, _createdAt DATETIME, _updatedAt DATETIME)', []);
for (var i = 0, j = value.length; i < j; i++){
doRequest(tx, value);
}
}
var db = window.openDatabase("SQLiteProjectList", "", "SQLiteProjectList", 1024 * 1000);
db.transaction(populateDB, onError, onSuccess);/pre
One more thing - as we can see you don't fill in elements with results of ProjectListDB_ProjectList_list_service. Most likely you use another service to do that. You need to call this service in function onSuccess described above:
prefunction onSuccess() {
console.log('all fine');
ServiceName.execute();
}/pre