samedi 25 juillet 2015

Getting variable outside of query block in Nodejs with sqlLite

I want to store all the rows from table to array(arr), I need to get the stored array outside of the defined query section. Is there a way I can get all the rows outside db.each such that I can manipulate them further.

var arr=[];
db.each("SELECT * FROM login", function(err, row) {
    var title=row.title;
    var context=row.context;
    var newItem = {
        'user': user,
        'pwd': pwd
    };
    arr.push(newItem);
});     
console.log(arr); //Outputs []

Aucun commentaire:

Enregistrer un commentaire