daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 36 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. promiseVersion(req, res) {
  2.     let data = {};
  3.     Product.create({
  4.             name: 'MacbookPro',
  5.             qty: 123,
  6.             price: 10000.9
  7.         })
  8.         .then(_product => {
  9.             data.product = _product;
  10.             return Order.findOne({
  11.                 orderNumber: 123
  12.             });
  13.         })
  14.         .then(_order => {
  15.             data.order = _order;
  16.             if (_order) {
  17.                 return ProductOrder.create({
  18.                     product: data.product.id,
  19.                     order: _order.id
  20.                 });
  21.             } else {
  22.                 return data;
  23.             }
  24.         })
  25.         .then((_prdocutData) => {
  26.             if (_prdocutData) data.ProductOrder = _prdocutData;
  27.             res.ok(data);
  28.         })
  29.         .catch(err => res.serverError(err));
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top