Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('can query (read)', function(done){
mysql.query('select * from users order by id asc', function(error, rows){
should.not.exist(error);
rows.length.should.equal(3);
rows[0].email.should.equal('evan@taskrabbit.com');
done();
});
});
it('can query (write) (data)', function(done){
mysql.query('INSERT INTO `users` (`id`, `email`, `first_name`, `counter`) VALUES (?, ?, ?, ?)', [5, 'saba@taskrabbit.com', 'saba', 30], function(error, response){
should.not.exist(error);
response.rows.should.equal(1);
done();
});
});
it('can query (write) (raw)', function(done){
mysql.query('INSERT INTO `users` (`id`, `email`, `first_name`, `counter`) VALUES (4, \'paul@taskrabbit.com\', \'paul\', 10)', function(error, response){
should.not.exist(error);
response.rows.should.equal(1);
done();
});
});
queryMysql: function (sql ,callback){
//console.log(sql);
mysql.query(sql,function(err,rows,fields){
if(err){
throw err;
}else{
callback(err,rows,fields);
}
//console.log('\n');for (var i in rows) {console.log(rows[i]);}
//console.log('\n');for (var i in fields) {console.log(fields[i]);}
});//mysql.end();
},
checkLogin: function (req, res, next) {
app.get('/', function(req, res){
mySql.query('SELECT * FROM test', function(error, result, fields){
if (error){
throw error;
}
Template.assign({
'values':fields
});
var Final = Template.fetchSync('data.html');
res.send(Final);
client.end();
});
});