Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Created July 12, 2017 20:16
Show Gist options
  • Save nomoney4me/45fb840740cbf53560a9cec0c700c363 to your computer and use it in GitHub Desktop.
Save nomoney4me/45fb840740cbf53560a9cec0c700c363 to your computer and use it in GitHub Desktop.
Promise.try(() => {
return Promise.all([
knex('course_requests').select('*'),
knex('course_requests').distinct('CourseTitle').select().groupBy('CourseTitle')
])
}).then(([allrecords, rows]) => {
/*
if rows: [
A: {
foo:bar,
value:key
},
B: {
foo:bar,
value,key
}
]
*/
return Promise.map(rows, (entry) => {
var obj = entry;
return Object.assign(entry, {obj})
})
}).then((data) => {
console.log(data)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment