refactor import usage. refactor invoices implementation

This commit is contained in:
Dzmitry_Tamashevich@epam.com
2020-11-03 12:22:02 +03:00
committed by Daniel Hutzel
parent bcfce87276
commit 3cf02cb567
9 changed files with 91 additions and 88 deletions

View File

@@ -0,0 +1,26 @@
const cds = require("@sap/cds");
module.exports = async function () {
const db = await cds.connect.to("db"); // connect to database service
const { Genres, Albums } = db.entities;
this.before("*", (req) => {
console.log(
"[USER]:",
req.user.id,
" [LEVEL]: ",
req.user.attr.level,
"[ROLE]",
req.user.is("user") ? "user" : "other"
);
});
this.on("addTrack", async (req) => {
const { albumTitle, genreName, name: trackName, composer } = req.data;
const genre = await db.run(SELECT.one(Genres).where({ name: genreName }));
const album = await db.run(SELECT.one(Albums).where({ title: albumTitle }));
// todo impl
});
};