Node.js에서의 Mysql의 자세한 사용법은 github 페이지를 참고하세요.

SELECT

var sql = 'SELECT * FROM table';
conn.query(sql, function(err, rows, fields){
	if(err){
		console.log(err);
	} else {
		for(var i=0; i<rows.length; i++){
			console.log(rows[i].name);
		}
	}
});

INSERT

var sql = 'INSERT INTO table (name, email, age) VALUES(?, ?, ?)';
var params = ['Jiwon', 'jiwon@mail.com', '23'];
conn.query(sql, params, function(err, rows, fields){
	if(err){
		console.log(err);
	} else {
		console.log(rows.insertId);
	}
});

UPDATE

var sql = 'UPDATE table SET name=?, age=? WHERE id=?';
var params = ['Eunji', '25', 1];
conn.query(sql, params, function(err, rows, fields){
	if(err){
		console.log(err);
	} else {
		console.log(rows);
	}
});

DELETE

var sql = 'DELETE FROM topic WHERE id=?';
var params = [1];
conn.query(sql, params, function(err, rows, fields){
	if(err){
		console.log(err);
	} else {
		console.log(rows);
	}
});