From 787af85c5214a9d74a59ccbc78c0ff5a35261966 Mon Sep 17 00:00:00 2001 From: Paul-Philippe Wortmann <65237023+TottySnowman@users.noreply.github.com> Date: Sat, 28 Oct 2023 19:34:28 +0200 Subject: [PATCH] updated post with UserID --- backend/src/controllers/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/controllers/index.ts b/backend/src/controllers/index.ts index 6af375a..f972c2e 100644 --- a/backend/src/controllers/index.ts +++ b/backend/src/controllers/index.ts @@ -51,6 +51,7 @@ app.get("/login", async (req: Request, res: Response) => { }); app.post("/history", async (req: Request, res: Response) => { + const { userID } = req.query; const data = req.body; console.log({ data }); @@ -60,8 +61,8 @@ app.post("/history", async (req: Request, res: Response) => { const session = driver.session(); try { const createdUserHistoryRel = await session.run( - "MATCH (u:User {surname : 'Doe'}) CREATE (h:History {createdAt: localdatetime()}) SET h += $history CREATE (u)-[:HAS_HISTORY]->(h)", - { history: data } + "MATCH (u:User where ID(u) = $userID) CREATE (h:History {createdAt: localdatetime()}) SET h += $history CREATE (u)-[:HAS_HISTORY]->(h)", + { history: data, userID: Number(userID) } ); return res.status(200).json({ response: "Inserted into history",