Skip to content

Instantly share code, notes, and snippets.

@lamp
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save lamp/23c62fa8913d8b0b413f to your computer and use it in GitHub Desktop.

Select an option

Save lamp/23c62fa8913d8b0b413f to your computer and use it in GitHub Desktop.
Code to scare David
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();
});
});
@dwhenry

dwhenry commented Jun 18, 2014

Copy link
Copy Markdown

I think this is the new NOW of how to write JS.. however I must admit WTF..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment