Updated to use srv-to-srv + declared events

This commit is contained in:
Daniel
2020-10-28 15:14:34 +01:00
committed by Daniel Hutzel
parent d9a06d16f1
commit df55110b9b
4 changed files with 15 additions and 14 deletions

View File

@@ -9,7 +9,6 @@ const cds = require ('@sap/cds')
cds.once('served', async ({CatalogService}) => {
const ReviewsService = await cds.connect.to('ReviewsService')
const messaging = await cds.connect.to('messaging')
// reflect entity definitions used below...
const { Books } = cds.entities('sap.capire.bookshop')
@@ -22,7 +21,7 @@ cds.once('served', async ({CatalogService}) => {
return SELECT(columns).from(Reviews).limit(limit).where({subject:String(id)})
}))
messaging.on ('reviewed', (msg) => {
ReviewsService.on ('reviewed', (msg) => {
console.debug ('> received:', msg.event, msg.data)
const { subject, rating } = msg.data
return UPDATE(Books,subject).with({rating})