bluebird - How to print query in console.log in Node.js using Promises -
i can print query using callbacks, query.sql print query. need when using promises. using bluebird library promises.
i adding code elaborate problem , adding dummy text post question. otherwise stackoverflow doesn't want let me post question , insist me add context explain code sections.
// sample code let query = conn.query('select * table ', (err,rows) => { console.log(query.sql); }); please explain
// actual code const qry = `select * field_slot field_id = 36 , day = lower(substr((dayname('"+req.body.date+"')),1,3)) , slot_id not in (select slot_id match_schedules field_id = ${req.body.field_id} , datetime_from between '2017-09-03 19:00:00' , '2017-09-03 23:59:59')`; console.log(qry); promise.using(mysql.getsqlconn(), conn => { conn.query(qry).then(slots => { res.json({ status: 200, data: slots }); }).catch(err => { res.json({ status: 500, message: 'error ' + err }); }); });
Comments
Post a Comment