mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Favor transaction functions over auto-commit
This commit is contained in:
parent
b1c5c4dbf9
commit
18ab7186f5
@ -24,18 +24,19 @@ export default {
|
|||||||
const { user } = await getUserAndBadge(params)
|
const { user } = await getUserAndBadge(params)
|
||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
try {
|
try {
|
||||||
// silly neode cannot remove relationships
|
await session.writeTransaction(transaction => {
|
||||||
await session.run(
|
return transaction.run(
|
||||||
`
|
`
|
||||||
MATCH (badge:Badge {id: $badgeKey})-[reward:REWARDED]->(rewardedUser:User {id: $userId})
|
MATCH (badge:Badge {id: $badgeKey})-[reward:REWARDED]->(rewardedUser:User {id: $userId})
|
||||||
DELETE reward
|
DELETE reward
|
||||||
RETURN rewardedUser
|
RETURN rewardedUser
|
||||||
`,
|
`,
|
||||||
{
|
{
|
||||||
badgeKey,
|
badgeKey,
|
||||||
userId,
|
userId,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
})
|
||||||
} finally {
|
} finally {
|
||||||
session.close()
|
session.close()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user