Files
cloud-cap-samples/bookshop/srv/admin-service.js
2021-04-14 19:38:38 +02:00

16 lines
429 B
JavaScript

// sqlite: FK constraint checks need to be enabled by application at runtime
// for each db connection
const cds = require('@sap/cds')
module.exports = cds.service.impl (async function(){
const db = await cds.connect.to('db')
if (db.kind === 'sqlite')
{
db.before('BEGIN', function (req) {
//console.log('--- PRAGMA foreign_keys = ON ---')
return this.dbc.run('PRAGMA foreign_keys = ON;')
})
}
})