{"size": 668, "ext": "js", "max_stars_repo_path": "server/db/initdb.js", "max_stars_repo_name": "zhiyuanFan/Nodejs-chat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/db/initdb.js", "max_issues_repo_name": "zhiyuanFan/Nodejs-chat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/db/initdb.js", "max_forks_repo_name": "zhiyuanFan/Nodejs-chat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.5555555556, "max_line_length": 61, "alphanum_fraction": 0.5763473054}
'use strict';

const sql = require('./sql');
const mysql = require('mysql');
const Promise = require('bluebird');
const config = require('../../config');

let db = mysql.createConnection({
  host : config.db_host,
  user : config.db_username,
  password : config.db_password,
  database : sql.DATABASE_NAME
})

/*
 * db init
 */
const INIT = () => {
  return new Promise((resolve,reject)=>{
    db.connect(function(err){
      if(err){
        reject(err);
      }
      db.query(sql.CREATE_IFILMO_CHAT_HISTORY,(err,result)=>{
        if(err){
          reject(err);
        }
        resolve(result);
        db.end();
      })
    });
  })
}

module.exports = INIT;
