Browse Source

Cleanup renamePlacenames

pull/426/head
Julian Simioni 9 years ago
parent
commit
a2950eebc4
  1. 12
      middleware/renamePlacenames.js

12
middleware/renamePlacenames.js

@ -40,24 +40,24 @@ var PARENT_PROPS = [
function setup() { function setup() {
return renamePlacenames; return renamePlacenames;
} }
function renamePlacenames(req, res, next) { function renamePlacenames(req, res, next) {
// do nothing if no result data set // do nothing if no result data set
if (!res || !res.data) { if (!res || !res.data) {
return next(); return next();
} }
res.data = res.data.map(renameStuff); res.data = res.data.map(renameOneRecord);
next(); next();
} }
function renameStuff(place) { /*
* Rename the fields in one record
*/
function renameOneRecord(place) {
if (place.address) { if (place.address) {
Object.keys(ADDRESS_PROPS).forEach(function (prop) { Object.keys(ADDRESS_PROPS).forEach(function (prop) {
place[ADDRESS_PROPS[prop]] = place.address[prop]; place[ADDRESS_PROPS[prop]] = place.address[prop];

Loading…
Cancel
Save