nodejsモジュールでデータベース接続を行っています。しかし、そのコールバックは呼び出されません。
これが私のモジュールです-
* getChapterList.js
var mysql=require('mysql');
var client=mysql.createClient({
user:'mysql',
password:''
});
client.useDatabase('test');
module.exports.get_chapter_list = function(subject_id){
client.query("select distinct chapter_id from course_associations where subject_id="+subject_id+" and status_id=1",
function(err,results,fields){
return results;
});
return "hello";
};
今、私はこのモジュールを次のように呼んでいます-
rs=require('./getChapterList');
rs.get_chapter_list(1);
// Output: hello
ただし、期待されるo/pは結果配列です。
グーグルでたくさん。しかし結果はありません。