@@ 150-174 (lines=25) @@ | ||
147 | return res.json(orders); |
|
148 | } |
|
149 | ||
150 | orderRows.forEach(function(order) { |
|
151 | db.all("SELECT " + orderItemsDataFields + " FROM order_items oi " + |
|
152 | " INNER JOIN products p ON oi.productId=p.productId" + |
|
153 | " AND oi.apiKey=p.apiKey WHERE oi.apiKey = ? AND oi.orderId = ?", |
|
154 | apiKey, |
|
155 | order.id, (err, orderItemRows) => { |
|
156 | if (err) { |
|
157 | return res.status(500).json({ |
|
158 | errors: { |
|
159 | status: 500, |
|
160 | source: "/order/search/" + query + " order_items", |
|
161 | title: "Database error", |
|
162 | detail: err.message |
|
163 | } |
|
164 | }); |
|
165 | } |
|
166 | ||
167 | order.order_items = orderItemRows; |
|
168 | orders.data.push(order); |
|
169 | ||
170 | if (orders.data.length === orderRows.length) { |
|
171 | res.json(orders); |
|
172 | } |
|
173 | }); |
|
174 | }); |
|
175 | }); |
|
176 | } |
|
177 | ||
@@ 36-60 (lines=25) @@ | ||
33 | return res.status(status).json(orders); |
|
34 | } |
|
35 | ||
36 | orderRows.forEach(function(order) { |
|
37 | db.all("SELECT " + orderItemsDataFields + " FROM order_items oi " + |
|
38 | "INNER JOIN products p ON oi.productId=p.productId AND oi.apiKey=p.apiKey" + |
|
39 | " WHERE oi.apiKey = ? AND oi.orderId = ?", |
|
40 | apiKey, |
|
41 | order.id, (err, orderItemRows) => { |
|
42 | if (err) { |
|
43 | return res.status(500).json({ |
|
44 | errors: { |
|
45 | status: 500, |
|
46 | source: "/orders order_items", |
|
47 | title: "Database error", |
|
48 | detail: err.message |
|
49 | } |
|
50 | }); |
|
51 | } |
|
52 | ||
53 | order.order_items = orderItemRows; |
|
54 | orders.data.push(order); |
|
55 | ||
56 | if (orders.data.length === orderRows.length) { |
|
57 | res.status(status).json(orders); |
|
58 | } |
|
59 | }); |
|
60 | }); |
|
61 | }); |
|
62 | } |
|
63 |