Do no longer use run blocks - removed in cds 4
This commit is contained in:
committed by
Christian Georgi
parent
5c5afd2790
commit
4b78a8b637
@@ -7,7 +7,7 @@ module.exports = cds.service.impl(function() {
|
|||||||
// Reduce stock of ordered books if available stock suffices
|
// Reduce stock of ordered books if available stock suffices
|
||||||
this.before ('CREATE', 'Orders', (req) => {
|
this.before ('CREATE', 'Orders', (req) => {
|
||||||
const { Items: OrderItems } = req.data
|
const { Items: OrderItems } = req.data
|
||||||
return cds.transaction(req) .run (()=> OrderItems.map (order =>
|
return cds.transaction(req) .run (OrderItems.map (order =>
|
||||||
UPDATE (Books) .where ('ID =', order.book_ID)
|
UPDATE (Books) .where ('ID =', order.book_ID)
|
||||||
.and ('stock >=', order.amount)
|
.and ('stock >=', order.amount)
|
||||||
.set ('stock -=', order.amount)
|
.set ('stock -=', order.amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user