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

Commit 92615757 by Thomas Watson Steen

Use ES5 `Object.keys` instead of Underscore.js `keys`

1 parent c05f7acc
......@@ -15,7 +15,7 @@ module.exports = (function() {
//fully qualify
where[self.__factory.connectorDAO.tableName+"."+self.__factory.identifier] = self.instance.id
var primaryKeys = Utils._.keys(self.__factory.connectorDAO.rawAttributes)
var primaryKeys = Object.keys(self.__factory.connectorDAO.rawAttributes)
, foreignKey = primaryKeys.filter(function(pk) { return pk != self.__factory.identifier })[0]
where[self.__factory.connectorDAO.tableName+"."+foreignKey] = {join: self.__factory.target.tableName+".id"}
......@@ -85,7 +85,7 @@ module.exports = (function() {
obsoleteAssociations.forEach(function(associatedObject) {
var where = {}
, primaryKeys = Utils._.keys(self.__factory.connectorDAO.rawAttributes)
, primaryKeys = Object.keys(self.__factory.connectorDAO.rawAttributes)
, foreignKey = primaryKeys.filter(function(pk) { return pk != self.__factory.identifier })[0]
, notFoundEmitters = []
......
......@@ -60,7 +60,7 @@ module.exports = (function() {
}
})
this.primaryKeyCount = Utils._.keys(this.primaryKeys).length;
this.primaryKeyCount = Object.keys(this.primaryKeys).length;
this.options.hasPrimaryKeys = this.hasPrimaryKeys = this.primaryKeyCount > 0;
addDefaultAttributes.call(this)
......@@ -182,7 +182,7 @@ module.exports = (function() {
} else if (Utils._.size(primaryKeys) && Utils.argsArePrimaryKeys(arguments, primaryKeys)) {
var where = {}
, self = this
, keys = Utils._.keys(primaryKeys)
, keys = Object.keys(primaryKeys)
Utils._.each(arguments, function(arg, i) {
var key = keys[i]
......
......@@ -74,7 +74,7 @@ module.exports = (function() {
Object.defineProperty(DAO.prototype, "identifiers", {
get: function() {
var primaryKeys = Utils._.keys(this.__factory.primaryKeys)
var primaryKeys = Object.keys(this.__factory.primaryKeys)
, result = {}
, self = this
......@@ -203,7 +203,7 @@ module.exports = (function() {
DAO.prototype.setAttributes = function(updates) {
var self = this
var readOnlyAttributes = Utils._.keys(this.__factory.primaryKeys)
var readOnlyAttributes = Object.keys(this.__factory.primaryKeys)
readOnlyAttributes.push('id')
readOnlyAttributes.push('createdAt')
......
......@@ -168,7 +168,7 @@ module.exports = (function() {
var queryResultHasJoin = function(results) {
if (!!results[0]) {
var keys = Utils._.keys(results[0])
var keys = Object.keys(results[0])
for (var i = 0; i < keys.length; i++) {
if (!!findTableNameInAttribute.call(this, keys[i])) {
......
......@@ -141,7 +141,7 @@ module.exports = (function() {
, association = dao.getAssociation(daoFactory)
if (association.connectorDAO) {
var foreignIdentifier = Utils._.keys(association.connectorDAO.rawAttributes).filter(function(attrName) {
var foreignIdentifier = Object.keys(association.connectorDAO.rawAttributes).filter(function(attrName) {
return (!!attrName.match(/.+Id$/) || !!attrName.match(/.+_id$/)) && (attrName !== association.identifier)
})[0]
......@@ -165,7 +165,7 @@ module.exports = (function() {
, aliasName = !!aliasAssoc ? Utils.addTicks(daoName) : _tableName
optAttributes = optAttributes.concat(
Utils._.keys(dao.attributes).map(function(attr) {
Object.keys(dao.attributes).map(function(attr) {
return '' +
[_tableName, Utils.addTicks(attr)].join('.') +
' AS ' +
......@@ -213,7 +213,7 @@ module.exports = (function() {
var replacements = {
table: Utils.addTicks(tableName),
attributes: Utils._.keys(attrValueHash).map(function(attr){return Utils.addTicks(attr)}).join(","),
attributes: Object.keys(attrValueHash).map(function(attr){return Utils.addTicks(attr)}).join(","),
values: Utils._.values(attrValueHash).map(function(value){
return Utils.escape((value instanceof Date) ? Utils.toSqlDate(value) : value)
}).join(",")
......
......@@ -216,7 +216,7 @@ module.exports = (function() {
, association = dao.getAssociation(daoFactory)
if (association.connectorDAO) {
var foreignIdentifier = Utils._.keys(association.connectorDAO.rawAttributes).filter(function(attrName) {
var foreignIdentifier = Object.keys(association.connectorDAO.rawAttributes).filter(function(attrName) {
return (!!attrName.match(/.+Id$/) || !!attrName.match(/.+_id$/)) && (attrName !== association.identifier)
})[0]
......@@ -240,7 +240,7 @@ module.exports = (function() {
, aliasName = !!aliasAssoc ? addQuotes(daoName) : _tableName
optAttributes = optAttributes.concat(
Utils._.keys(dao.attributes).map(function(attr) {
Object.keys(dao.attributes).map(function(attr) {
return '' +
[_tableName, addQuotes(attr)].join('.') +
' AS "' +
......@@ -302,7 +302,7 @@ module.exports = (function() {
var replacements = {
table: addQuotes(tableName),
attributes: Utils._.keys(attrValueHash).map(function(attr){return addQuotes(attr)}).join(","),
attributes: Object.keys(attrValueHash).map(function(attr){return addQuotes(attr)}).join(","),
values: Utils._.values(attrValueHash).map(function(value){
return pgEscape(value)
}).join(",")
......
......@@ -71,7 +71,7 @@ module.exports = (function() {
var replacements = {
table: Utils.addTicks(tableName),
attributes: Utils._.keys(attrValueHash).map(function(attr){return Utils.addTicks(attr)}).join(","),
attributes: Object.keys(attrValueHash).map(function(attr){return Utils.addTicks(attr)}).join(","),
values: Utils._.values(attrValueHash).map(function(value){
return escape((value instanceof Date) ? Utils.toSqlDate(value) : value)
}).join(",")
......
......@@ -63,7 +63,7 @@ var Utils = module.exports = {
].join(" ")
},
argsArePrimaryKeys: function(args, primaryKeys) {
var result = (args.length == Utils._.keys(primaryKeys).length)
var result = (args.length == Object.keys(primaryKeys).length)
if (result) {
Utils._.each(args, function(arg) {
if(result) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!