Skip to content

Instantly share code, notes, and snippets.

@ZZR-china
Created November 24, 2016 05:48
Show Gist options
  • Save ZZR-china/4a83bff0eeaa895bf38564bf7709817b to your computer and use it in GitHub Desktop.
Save ZZR-china/4a83bff0eeaa895bf38564bf7709817b to your computer and use it in GitHub Desktop.
const getOrderById = (_id)=> {
return new Promise((resolve, reject)=>{
order_item_mongo.aggregate([{
$match: {order_id: id}
}, {
$group : {
// _id : "$menu_id",
_id: { menu_id:"$menu_id", menu_name:"$menu_name"},
products: { $push: { product_name: "$product_name"} }
}
}], (err, docs) => {
if (docs) {
resolve(docs)
}else{
reject('get group orderitem fail')
}
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment