Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Last active July 12, 2017 16:49
Show Gist options
  • Save nomoney4me/08a4a7ae99f8b676464e8b1f0babf6af to your computer and use it in GitHub Desktop.
Save nomoney4me/08a4a7ae99f8b676464e8b1f0babf6af to your computer and use it in GitHub Desktop.
Promise.try(() => {
return Promise.all([
knex('course_requests').select('*'),
knex.raw('select distinct(CourseTitle) as courses from course_requests group by CourseTitle')
])
}).then(([allrecords, rows]) => {
console.log(rows)
})
/* Console.log(rows)
[
RowDataPacket { courses: 'French I' },
RowDataPacket { courses: 'French II' },
RowDataPacket { courses: 'French III' },
RowDataPacket { courses: 'French III Honors' },
RowDataPacket { courses: 'French IV' },
RowDataPacket { courses: 'French V' },
RowDataPacket { courses: 'G Block Free' },
...
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment