Skip to content

Instantly share code, notes, and snippets.

@jibwa
Created April 16, 2017 03:17
Show Gist options
  • Save jibwa/6eb68778a22957fa9dbbb87b9cd2a4e3 to your computer and use it in GitHub Desktop.
Save jibwa/6eb68778a22957fa9dbbb87b9cd2a4e3 to your computer and use it in GitHub Desktop.
Plain es6 promise solution to async with followup and collecting args for response
Promise.all([
Product.create({
name: 'MacbookPro',
qty: 1232213,
price: 10000.
}),
Order.findOne({
orderNumber: 123
})
])
.then(([product, order]) =>
ProductOrder.create({
product: product.id,
order: order.id
})
.then(productOrder => res.ok(product, order, productOrder))
)
.catch(res.negotiate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment