Created
October 13, 2018 14:40
-
-
Save klogic/399076f91b579f03ce37432cfed662ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let promises = [] | |
promises.push( | |
Orders | |
.find() | |
.sort('-create') | |
.lean() | |
.then((result) => { | |
return result; | |
}) | |
); | |
Promise | |
.all(promises) | |
.then((data) => { | |
let objresult = {} | |
data.forEach(item => { | |
// store data to object[orderid] | |
objresult[item.orderid] = item.ordervalue | |
}) | |
// loop object for get data that we want | |
Object.keys(objresult).forEach(item => { | |
// calculate data | |
}) | |
res.status(200).json({ | |
reponse | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment