Created
July 12, 2017 20:16
-
-
Save nomoney4me/45fb840740cbf53560a9cec0c700c363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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