Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Last active July 12, 2017 19:52
Show Gist options
  • Save nomoney4me/79ac48bacfdfcfec1845b652e6375ed2 to your computer and use it in GitHub Desktop.
Save nomoney4me/79ac48bacfdfcfec1845b652e6375ed2 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]) => {
var obj = rows;
/* I'm trying to take each of the data and insert the object of itself: something like this
Turning [A,B,C,D,E] into => [A: {A,B,C,D,E}, B:{A,B,C,D,E}, C:{A,B,C,D,E}, etc...you get the point..]
*/
return Promise.map(rows, row => {
Object.assign(row, {obj})
})
}).then((data) => {
console.log(data)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment