composites

This commit is contained in:
Daniel
2020-11-16 22:27:40 +01:00
committed by Daniel Hutzel
parent d0d08b1ee1
commit f2c37ec162
43 changed files with 325 additions and 212 deletions

View File

@@ -0,0 +1,12 @@
const cds = require('@sap/cds')
module.exports = cds.service.impl (function(){
this.before ('NEW','Authors', genid)
this.before ('NEW','Books', genid)
})
/** Generate primary keys for target entity in request */
async function genid (req) {
const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID'))
req.data.ID = ID - ID % 100 + 100 + 1
}