Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

Commit

Permalink
Fixes convert-bad-dob-format lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SCdF committed Apr 20, 2016
1 parent be50823 commit 1ddae89
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions migrations/convert-bad-dob-format.js
@@ -1,10 +1,12 @@
var async = require('async'),
db = require('../db'),
var db = require('../db'),
moment = require('moment');

/* jshint ignore:start */
// (it's more readable to use double quotes)
var temporaryView = {
"map": "function(doc) { if (doc.type === 'person' && doc.date_of_birth && doc.date_of_birth.indexOf(' ') >= 0) { emit(1); }}"
'map': "function(doc) { if (doc.type === 'person' && doc.date_of_birth && doc.date_of_birth.indexOf(' ') >= 0) { emit(1); }}"

This comment has been minimized.

Copy link
@mandric

mandric Apr 20, 2016

Contributor

maybe even more readable is:

var map = function(doc) { ... };
var tempView = { map: map.toString() };

This comment has been minimized.

Copy link
@SCdF

SCdF Apr 20, 2016

Author Contributor

Ohhhh yeah I forgot you can do that! 👍

};
/* jshint ignore:end */

module.exports = {
name: 'convert-bad-dob-format',
Expand All @@ -23,12 +25,9 @@ module.exports = {
return row.doc;
});

for(doc of docs) {
var currentDob = doc.date_of_birth;
var convertedDob = moment(doc.date_of_birth, 'MMM Do, YYYY').format('YYYY-MM-DD');

doc.date_of_birth = convertedDob;
}
docs.forEach(function(doc) {
doc.date_of_birth = moment(doc.date_of_birth, 'MMM Do, YYYY').format('YYYY-MM-DD');
});

db.medic.bulk({
docs: docs
Expand Down

0 comments on commit 1ddae89

Please sign in to comment.