Thursday 27 April 2017

how to insert this object to mysql db in nodejs using mysql-crud

I am new to nodejs and mysql. I want insert this data to mysql using nodejs. i tried with and without mysql-crud modules but failed. Can anyone help me?

exports.insertquotereq = function(req, res){

        var chat_data = {
            to_country: req.whereto,
            to_airport: req.toairport,
            from_country: req.fromwhere,
            from_airport: req.fromairport,
            planetype: req.planetype,
            startdate: req.startdate,
            starttime: req.starttime,
            returndate: req.returndate,
            returntime: req.returndate,
            email: req.email,
            distance: req.distance,
            estimatedhrs: req.estimatedhrs,
            planecostperhr: req.planecostperhr,
            estimatedcost: req.estimatedcost,
            estimated_time: req.estimated_time
        };
        //console.log('chat_data',chat_data);
        var insert = connection.query("INSERT INTO chat SET ?", chat_data, function(err, result){
            if(err) throw err;
            console.log('data inserted'+insert);
        });

};

thanks in advance



via Naim Jeem

No comments:

Post a Comment