Last active
August 29, 2015 14:02
-
-
Save lamp/23c62fa8913d8b0b413f to your computer and use it in GitHub Desktop.
Code to scare David
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
| new Sequelize.Utils.QueryChainer() | |
| .add( | |
| req.field.getHarvests() | |
| ) | |
| .add( | |
| req.field.getApplications() | |
| ) | |
| .add( | |
| req.field.getPlantings() | |
| ) | |
| .add( | |
| req.field.getObservations() | |
| ) | |
| .add( | |
| req.field.getSprayings() | |
| ) | |
| .add( | |
| req.field.getIrrigations() | |
| ) | |
| .add( | |
| req.field.getCustoms() | |
| ) | |
| .run() | |
| .success(function(results){ | |
| var json = []; | |
| var activities = _.reduce(results, function(memo, activitiesOfType){ | |
| return memo.concat(activitiesOfType); | |
| }, []); | |
| Promise.map(activities, function(activity){ | |
| return activity.asJson(); | |
| }).then(function(formatted){ | |
| json = json.concat(formatted); | |
| }).finally(function(){ | |
| res.body = json; | |
| next(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is the new NOW of how to write JS.. however I must admit WTF..