cds.deploy++

This commit is contained in:
Daniel
2021-03-23 20:00:37 +01:00
parent 049345a39c
commit 6e88453dea
3 changed files with 22 additions and 2 deletions

View File

@@ -16,8 +16,9 @@
"cds": {
"requires": {
"db": {
"kind": "sql"
"kind": "sqlite",
"model": "*"
}
}
}
}
}

BIN
bookshop/sqlite.db Normal file

Binary file not shown.

19
bookshop/srv/server.js Normal file
View File

@@ -0,0 +1,19 @@
const cds = require ('@sap/cds')
cds.on('served', async ()=>{ try {
console.log ('\nFilling database with initial data...')
const m = cds.model.minified() //> we likely should do that by default
const tx = cds.tx()
tx.run ([ //> this will be replaced by
DELETE.from ('sap.capire.bookshop.Authors'),
DELETE.from ('sap.capire.bookshop.Books'),
DELETE.from ('sap.capire.bookshop.Books.texts'),
DELETE.from ('sap.capire.bookshop.Genres'),
DELETE.from ('sap.common.Currencies'),
DELETE.from ('sap.common.Currencies.texts'),
])
await cds.deploy(m).to(tx,{ddl:false})
await tx.commit()
} catch(e) { console.error(e) }})
module.exports = cds.server