不要怂,就是干,撸起袖子干!

Commit 586a854c by sdepold

formatting

1 parent 473bce05
var Utils = require("./utils")
, Mixin = require("./associations/mixin")
, Validator = require("validator")
var Utils = require("./utils")
, Mixin = require("./associations/mixin")
, DataTypes = require("./data-types")
, Validator = require("validator")
module.exports = (function() {
var DAO = function(values, options) {
......@@ -223,7 +224,7 @@ module.exports = (function() {
DAO.prototype.setValidators = function(attribute, validators) {
this.validators[attribute] = validators
}
DAO.prototype.toJSON = function() {
return this.values;
}
......
var Utils = require("../../utils")
, util = require("util")
var Utils = require("../../utils")
, DataTypes = require("../../data-types")
, util = require("util")
module.exports = (function() {
var QueryGenerator = {
......@@ -271,14 +272,26 @@ module.exports = (function() {
var template = "<%= type %>"
, replacements = { type: dataType.type }
if(dataType.hasOwnProperty('allowNull') && (!dataType.allowNull)) template += " NOT NULL"
if(dataType.autoIncrement) template +=" auto_increment"
if(dataType.defaultValue != undefined) {
if(dataType.hasOwnProperty('allowNull') && (!dataType.allowNull)) {
template += " NOT NULL"
}
if(dataType.autoIncrement) {
template +=" auto_increment"
}
if((dataType.defaultValue != undefined) && (dataType.defaultValue != DataTypes.NOW)) {
template += " DEFAULT <%= defaultValue %>"
replacements.defaultValue = Utils.escape(dataType.defaultValue)
}
if(dataType.unique) template += " UNIQUE"
if(dataType.primaryKey) template += " PRIMARY KEY"
if(dataType.unique) {
template += " UNIQUE"
}
if(dataType.primaryKey) {
template += " PRIMARY KEY"
}
result[name] = Utils._.template(template)(replacements)
} else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!