Last active
January 11, 2017 04:38
-
-
Save JeffML/3202cad046ab72d117760aa63c01027c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
var PouchDB = require('pouchdb'); | |
var db = new PouchDB('choices'); | |
db.allDocs({ | |
include_docs: true | |
}) | |
.then(docs => { | |
_.each(docs.rows, r => { | |
r.doc.taste = palatability(); | |
db.put(r.doc); | |
}); | |
}); | |
function palatability() { | |
var scale = Math.round(Math.random() * 10); | |
var taste; | |
switch (true) { | |
// this switch is a horrible hack; don't ever do this ;-P | |
case (scale < 2): | |
taste = "ugh"; | |
break; | |
case (scale < 5): | |
taste = "meh"; | |
break; | |
case (scale < 8): | |
taste = "tasty"; | |
break; | |
default: | |
taste = "sublime"; | |
break; | |
} | |
return taste; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment