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

Commit b987a80f by Jan Aagaard Meier

Making the code climate a bit nice

1 parent 3f510d83
...@@ -127,7 +127,7 @@ module.exports = (function() { ...@@ -127,7 +127,7 @@ module.exports = (function() {
// inject the node-sql methods to the dao factory in order to // inject the node-sql methods to the dao factory in order to
// receive the syntax sugar ... // receive the syntax sugar ...
(function() { (function() {
var instance = sql.define({ name: 'dummy', columns: [] }); var instance = sql.define({ name: 'dummy', columns: [] });
for (var methodName in instance) { for (var methodName in instance) {
...@@ -1083,7 +1083,7 @@ module.exports = (function() { ...@@ -1083,7 +1083,7 @@ module.exports = (function() {
options = Utils._.extend({ options = Utils._.extend({
transaction: null transaction: null
}, options ||  {}); }, options || {});
if (!(where instanceof Utils.or) && !(where instanceof Utils.and) && !Array.isArray(where)) { if (!(where instanceof Utils.or) && !(where instanceof Utils.and) && !Array.isArray(where)) {
for (var attrname in where) { for (var attrname in where) {
......
...@@ -339,23 +339,6 @@ var Utils = module.exports = { ...@@ -339,23 +339,6 @@ var Utils = module.exports = {
return ''; return '';
} }
}, },
hasChanged: function(attrValue, value) {
//If attribute value is Date, check value as a date
if (Utils._.isDate(attrValue) && !Utils._.isDate(value)) {
value = new Date(value);
}
if (Utils._.isDate(attrValue)) {
return attrValue.valueOf() !== value.valueOf();
}
//If both of them are empty, don't set as changed
if ((attrValue === undefined || attrValue === null || attrValue === '') && (value === undefined || value === null || value === '')) {
return false;
}
return attrValue !== value;
},
argsArePrimaryKeys: function(args, primaryKeys) { argsArePrimaryKeys: function(args, primaryKeys) {
var result = (args.length === Object.keys(primaryKeys).length); var result = (args.length === Object.keys(primaryKeys).length);
if (result) { if (result) {
...@@ -427,18 +410,6 @@ var Utils = module.exports = { ...@@ -427,18 +410,6 @@ var Utils = module.exports = {
return true; return true;
}, },
setAttributes: function(hash, identifier, instance, prefix) {
prefix = prefix || '';
if (this._.isPlainObject(identifier)) {
this._.each(identifier, function(elem, key) {
hash[prefix + key] = Utils._.isString(instance) ? instance : Utils._.isObject(instance) ? instance[elem.key || elem] : null;
});
} else {
hash[prefix + identifier] = Utils._.isString(instance) ? instance : Utils._.isObject(instance) ? instance.id : null;
}
return hash;
},
removeNullValuesFromHash: function(hash, omitNull, options) { removeNullValuesFromHash: function(hash, omitNull, options) {
var result = hash; var result = hash;
...@@ -461,14 +432,6 @@ var Utils = module.exports = { ...@@ -461,14 +432,6 @@ var Utils = module.exports = {
return result; return result;
}, },
firstValueOfHash: function(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return obj[key];
}
return null;
},
inherit: function(SubClass, SuperClass) { inherit: function(SubClass, SuperClass) {
if (SuperClass.constructor === Function) { if (SuperClass.constructor === Function) {
// Normal Inheritance // Normal Inheritance
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!