X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=room.js;fp=room.js;h=950fa369159c65d0194a997bcbb8c65d65555da3;hb=f1b33cf06fa5a63db6715de7ac205c143d3499c3;hp=a5ff81c98f3501117d8f4712c776283c246e7770;hpb=1ed9431031547433266a3b76fbe5c360d001af76;p=webchat%2FWebChat.git diff --git a/room.js b/room.js index a5ff81c..950fa36 100644 --- a/room.js +++ b/room.js @@ -3,14 +3,7 @@ module.exports = function() { var _this = this; var config = require("./configure.js"); - var MySQLPool = new require("./mysql_pool.js"); - var pool = new MySQLPool({ - host : config.db_host, - user : config.db_user, - password : config.db_password, - port : config.db_port, - database : config.db_name, - }); + var RoomInfomationModel = require("./init").GetRoomInfomation; var collection = {}; this.Get = function(rno){ return collection[rno]; @@ -45,7 +38,7 @@ module.exports = function() var async = require("async"); async.waterfall([ function(next){ - pool.query("TRUNCATE TABLE rooms",null,next); + RoomInfomationModel.drop().done(next); }, function(result,next){ var util = require("util"); @@ -72,7 +65,8 @@ module.exports = function() Add(rno,password,romonly); items.push(new Array(rno,password,romonly)); } - pool.query("INSERT INTO rooms VALUES ?",[items],callfunc); + newRoom = RoomInfomationModel.build(items); + newRoom.save().done(next); } ],callfunc); } @@ -81,13 +75,12 @@ module.exports = function() var async = require("async"); async.waterfall([ function(next){ - pool.query("SELECT * FROM rooms",null,next); + RoomInfomationModel.findAll().done(next); }, function(result,next){ for(var i = 0; i < result.length; i++) { - //MySQL‚Å‚ÍTINYINT‚ªŽg‚í‚ê‚Ä‚¢‚é - Add(result[i].number,result[i].password,result[i].hiddenlog != 0); + Add(result[i].number,result[i].password,result[i].hiddenlog); } next(null,null); }