fixed accidential push

This commit is contained in:
Daniel
2022-04-09 12:38:24 +02:00
parent bf317bc2c9
commit b733643f2a
3 changed files with 55 additions and 13 deletions

View File

@@ -1,20 +1,13 @@
const cds = require('@sap/cds')
class CatalogService extends cds.ApplicationService { async init(){
class CatalogService extends cds.ApplicationService { init(){
const { Books } = cds.entities ('sap.capire.bookshop')
const { ListOfBooks } = this.entities
this.on('READ','ListOfBooks', ()=>{
Error.stackTraceLimit = 22
cds._debug = true
return SELECT.from (ListOfBooks)
})
// Reduce stock of ordered books if available stock suffices
this.on ('submitOrder', async req => {
const {book,quantity} = req.data
if (quantity < 1) return req.reject (400,`quantity has to be 1 or more`)
cds._debug = true
let b = await SELECT `stock` .from (Books,book)
if (!b) return req.error (404,`Book #${book} doesn't exist`)
let {stock} = b
@@ -29,8 +22,7 @@ class CatalogService extends cds.ApplicationService { async init(){
if (each.stock > 111) each.title += ` -- 11% discount!`
})
await super.init()
return
return super.init()
}}
module.exports = { CatalogService }

View File

@@ -16,9 +16,9 @@ GET {{server}}/browse/$metadata
### ------------------------------------------------------------------------
# Browse Books as any user
GET {{server}}/browse/Books?
GET {{server}}/browse/ListOfBooks?
# &$select=title,stock
# &$expand=currency
&$expand=genre
# &sap-language=de
{{me}}