Skip to content

Commit

Permalink
Fix missing product in pickProduct
Browse files Browse the repository at this point in the history
PR-URL: QOTEQ#9
  • Loading branch information
georgolden authored and tshemsedinov committed Apr 28, 2022
1 parent e995706 commit 1983f70
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions application/domain/store/pickProduct.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
async ({ order, product }) => {
const { orderId, amount } = order;
async ({ order }) => {
const { orderId, amount, productId } = order;
const product = await db.pg.row('Product', ['*'], { productId });
const { weight } = product;
const postPackage = {
orderId,
weight: weight * amount,
};
await db.pg.insert('Package', postPackage);
return postPackage;
const { rows } = await db.pg
.insert('Package', postPackage)
.returning('packageId');
const { packageId } = rows[0];
return { ...postPackage, packageId };
};

0 comments on commit 1983f70

Please sign in to comment.