hmm: Request Error

Beitrag lesen

wenn ich das so versuche:

  this.generateOneUpdate = function(email, data) {
        var dbLokal = new sqlite3.Database(dbRef);
        
        var statment = SQL_INSERT_MITARBEITER.replace(/\?name/g, "'" + data.name + "'");
        dbLokal.run(statment);
        console.log("generateOneUpdate");
        function callback(user_id, m_id, data) {
            console.log("callback");
            //var dbLokal = new sqlite3.Database(dbRef);
            var statmentLokal = SQL_INSERT_USER_MITARBEITER.replace(/\?user_id/g, user_id);
            statmentLokal = statmentLokal.replace(/\?m_id/g, m_id);
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);
            statmentLokal = SQL_INSERT_SKILL.replace(/\?m_id/g, m_id);
            statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
            statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
            statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);
            statmentLokal = SQL_REPLACE_SKILL.replace(/\?m_id/g, m_id);
            statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
            statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
            statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);
            //dbLokal.close();
        }
        
        statment = SQL_SELECT_USER_MITARBEITER_ID.replace(/\?email/g, "'" + email + "'");
        statment = statment.replace(/\?name/g, "'" + data.name + "'");
        console.log("select:");
        console.log(statment);
        
        dbLokal.run(statment, function(err, rows) {
            console.log("test");
            console.log(rows);
            var array = rows;
            
            for(var i = 0; i < array.length; i++) {
                console.log(array[i]);
            }
            
            /*var lastIndex = rows.length - 1;
            var user_id = rows[lastIndex].user_id;
            var m_id = rows[lastIndex].mitarbeiter_id;*/
            //callback(rows[lastIndex].user_id, rows[lastIndex].mitarbeiter_id, data);
            
            /*var statmentLokal = SQL_INSERT_USER_MITARBEITER.replace(/\?user_id/g, user_id);
            statmentLokal = statmentLokal.replace(/\?m_id/g, m_id);
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);
            statmentLokal = SQL_INSERT_SKILL.replace(/\?m_id/g, m_id);
            statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
            statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
            statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);
            statmentLokal = SQL_REPLACE_SKILL.replace(/\?m_id/g, m_id);
            statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
            statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
            statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
            console.log(statmentLokal + "\n");
            dbLokal.run(statmentLokal);*/
        });
        
        dbLokal.close();
    }

bekomme ich folgenden fehler:

generateOneUpdate
select:
select user_id, mitarbeiter_id from user, mitarbeiter where user.email = 'wyczisk@gmx.de' and mitarbeiter.name = 'a';
generateOneUpdate
select:
select user_id, mitarbeiter_id from user, mitarbeiter where user.email = 'wyczisk@gmx.de' and mitarbeiter.name = 'Christopher';
generateOneUpdate
select:
select user_id, mitarbeiter_id from user, mitarbeiter where user.email = 'wyczisk@gmx.de' and mitarbeiter.name = 'Christopher';
generateOneUpdate
select:
select user_id, mitarbeiter_id from user, mitarbeiter where user.email = 'wyczisk@gmx.de' and mitarbeiter.name = 'Jens';
generateOneUpdate
select:
select user_id, mitarbeiter_id from user, mitarbeiter where user.email = 'wyczisk@gmx.de' and mitarbeiter.name = 'a';
test
undefined
/home/ubuntu/workspace/node_modules/sqlite3/lib/trace.js:27
                    throw err;
                    ^

TypeError: Cannot read property 'length' of undefined
    at Statement.<anonymous> (/home/ubuntu/workspace/skillmatrixtool/js/database/dbManager.js:71:37)
--> in Statement#run([Function])
    at Database.<anonymous> (/home/ubuntu/workspace/node_modules/sqlite3/lib/sqlite3.js:75:19)
    at Database.<anonymous> (/home/ubuntu/workspace/node_modules/sqlite3/lib/sqlite3.js:21:19)
    at DbManager.generateOneUpdate (/home/ubuntu/workspace/skillmatrixtool/js/database/dbManager.js:66:17)
    at /home/ubuntu/workspace/skillmatrixtool/js/view/services.js:59:27
    at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:95:5)