waterline
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -41,3 +41,22 @@ /** | ||
var collectionName = _.find(self.query.waterline.schema, {tableName: self.collection}).identity; | ||
// Create a mapping of column names -> attribute names | ||
var columnNamesMap = _.reduce(self.query.waterline.schema[collectionName].attributes, function(memo, val, key) { | ||
// If the attribute has a custom column name, use it as the key for the mapping | ||
if (val.columnName) { | ||
memo[val.columnName] = key; | ||
} | ||
// Otherwise just use the attribute name | ||
else { | ||
memo[key] = key; | ||
} | ||
return memo; | ||
}, {}); | ||
// Transform column names into attribute names using the columnNamesMap | ||
attrs = _.keys(attrs).map(function(key) { | ||
return columnNamesMap[key]; | ||
}); | ||
// | ||
@@ -66,3 +85,3 @@ // TODO: | ||
// on SQL databases the query will fail with "unknown field" error. | ||
self.find({select: _.keys(attrs)}, function (err, existingData) { | ||
self.find({select: attrs}, function (err, existingData) { | ||
@@ -69,0 +88,0 @@ if (err) { |
{ | ||
"name": "waterline", | ||
"description": "An ORM for Node.js and the Sails framework", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"homepage": "http://github.com/balderdashy/waterline", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
326286
8708