now create tracks method works properly
This commit is contained in:
committed by
Daniel Hutzel
parent
3d176237c1
commit
6454019713
@@ -16,6 +16,6 @@ const locale = getLocaleFromLS();
|
||||
changeUserDefaults(user);
|
||||
changeLocaleDefaults(locale);
|
||||
|
||||
axiosInstance.interceptors.response.use(null, responseErrorInterceptor);
|
||||
// axiosInstance.interceptors.response.use(null, responseErrorInterceptor);
|
||||
|
||||
export { axiosInstance, changeLocaleDefaults, changeUserDefaults };
|
||||
|
||||
@@ -40,11 +40,6 @@ const ErrorPage = () => {
|
||||
<Button onClick={onGoHome} type="primary">
|
||||
Back Home
|
||||
</Button>
|
||||
{!user && (
|
||||
<Button onClick={goLoginPage} type="primary">
|
||||
Login
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -4,14 +4,22 @@ module.exports = async function () {
|
||||
const db = await cds.connect.to("db"); // connect to database service
|
||||
|
||||
this.on("CREATE", "*", async (req) => {
|
||||
const selectLastQuery = SELECT.one(req.entity)
|
||||
.orderBy({ ID: "desc" });
|
||||
|
||||
const transaction = await db.tx(req);
|
||||
let { ID: lastEntityID } = await transaction.run(
|
||||
SELECT.one(req.entity).columns("ID").orderBy({ ID: "desc" })
|
||||
);
|
||||
|
||||
let { ID: lastEntityID } = await transaction.run(selectLastQuery);
|
||||
|
||||
const columns = ["ID", ...Object.keys(req.data)];
|
||||
const values = [++lastEntityID, ...Object.values(req.data)];
|
||||
const insertQuery = INSERT.into(req.entity).columns(columns).values(values);
|
||||
|
||||
await transaction.run(insertQuery);
|
||||
const result = await transaction.run(selectLastQuery);
|
||||
|
||||
await transaction.run(req.query.columns(columns).values(values));
|
||||
await transaction.commit();
|
||||
|
||||
return result;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user