Skip to content

Instantly share code, notes, and snippets.

@mezod
Created March 11, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mezod/5a9a70efa8a2f5c078cbc75550c0a87b to your computer and use it in GitHub Desktop.
Save mezod/5a9a70efa8a2f5c078cbc75550c0a87b to your computer and use it in GitHub Desktop.
* get(params, user_id) {
const query = knex
.select(['habits.*',
'dates.created_at as dates_created_at', 'dates.date', 'dates.skip'])
.where({ user_id })
.orderBy('position', 'ASC')
.from('habits');
if (params.stats) {
query.leftJoin('dates', 'habits.id', '=', 'dates.habit_id');
}
return yield query
.then(habits => habits);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment