Skip to content

Commit

Permalink
updated post with UserID
Browse files Browse the repository at this point in the history
  • Loading branch information
TottySnowman committed Oct 28, 2023
1 parent bd6f5e1 commit 787af85
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/src/controllers/index.ts
Expand Up @@ -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 });
Expand All @@ -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",
Expand Down

0 comments on commit 787af85

Please sign in to comment.