Tuesday, 6 June 2017

return value inside db function on res render

i want make a helper and will be used in my view (pug), so i send a function as data to the view file, but the problem is, my helper / passed function wont return a value or == undefined in my view, pug, thanks

    app.get('/admin/pengguna', function(req,res){
    db.all("SELECT * FROM main_posts WHERE wdyw='2'", function(err, rows) {
        //var r = db.all("SELECT * FROM main_posts WHERE wdyw='1' AND ")
        if (!err) {
            res.render('admin/pengguna', {
                path: req.path,
                pengguna : rows,
                useringroup: function(w) {
                    return w;
                    db.all("SELECT * FROM main_posts WHERE wdyw='1' AND identity= $w", { $w: w }, function(err, result){
                        return result.lenght;
                    })
                }
            })
        }
    })
})

myview app.js



via Rubi Jihantoro

No comments:

Post a Comment