{"size": 1124, "ext": "js", "max_stars_repo_path": "config/orm.js", "max_stars_repo_name": "minujames/burger", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "config/orm.js", "max_issues_repo_name": "minujames/burger", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "config/orm.js", "max_forks_repo_name": "minujames/burger", "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": 24.9777777778, "max_line_length": 71, "alphanum_fraction": 0.5880782918}
var connection = require("./connection.js");

var orm = {
  all: function(table, callBack){
    var queryStr = "SELECT * FROM " + table + ";";
    connection.query(queryStr, function(error, result){
      if(error){
        throw error;
      }
      callBack(result);
    });
  },

  create: function(table, objColVals, callBack){
    var queryString = "INSERT INTO " + table + " SET ? ";
    connection.query(queryString, objColVals, function(error, result) {
      if (error) {
        throw error;
      }
      callBack(result);
    });
  },

  update: function(table, objColVals, condition, callBack){
    var queryString = "UPDATE " + table + " SET ? WHERE " + condition;
    connection.query(queryString, objColVals, function(error, result) {
      if (error) {
        throw error;
      }
      callBack(result);
    });
  },

  delete: function(table, condition, callBack){
    var queryString = "DELETE FROM " + table + " WHERE " + condition;
    connection.query(queryString, function(error, result) {
      if (error) {
        throw error;
      }
      callBack(result);
    });
  }
};

module.exports = orm;