module.exports = {
//1 걸그룹 리스트 조회
//gid 걸그룹이름 데뷔일 히트곡명
//완료
getGroupList: function(callback) {
const conn = this.getConnection();
const sql = `
SELECT girl_group.gid, girl_group.name, date_format(girl_group.debut, '%Y-%m-%d' ) as debut, song.title
FROM song
JOIN girl_group
ON song.sid = girl_group.hit_song_id;
`;
conn.query(sql, (err, rows, fields) => {
if (err)
throw err;
callback(rows);
});
conn.end();
}
}
에서
module.exports = { } 안에서 module.exports를 불러올 때 this를 사용한다
예를들면 this안의 펑션인 getGroupList 를
module.exports = { } 의 { } 안에서 불러올 땐 this.getGroupList 이렇게
밖에서 부를 땐 module.exports.getGroupList 이렇게