Saturday, 27 May 2017

How do I assign a sqlite3 database result into a global variable

I have this code:

var query = 'SELECT postName FROM post WHERE id = ' + id;

db.get(query, function dato(err, row) {
    if (err){
        console.log(err);
    }else{
        console.log(row.postName); // works!
        return row.postName;
    }
});

Can you help me to know the way for store row.postName into a global variable?



via estebancito

No comments:

Post a Comment