mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
31 lines
842 B
JavaScript
31 lines
842 B
JavaScript
export default {
|
|
Mutation: {
|
|
disable: async (object, params, { user, driver }) => {
|
|
const { resource: { id } } = params
|
|
const { id: userId } = user
|
|
const cypher = `
|
|
MATCH (u:User {id: $userId})
|
|
MATCH (r {id: $id})
|
|
SET r.disabled = true
|
|
MERGE (r)<-[:DISABLED]-(u)
|
|
`
|
|
const session = driver.session()
|
|
const res = await session.run(cypher, { id, userId })
|
|
session.close()
|
|
return Boolean(res)
|
|
},
|
|
enable: async (object, params, { user, driver }) => {
|
|
const { resource: { id } } = params
|
|
const cypher = `
|
|
MATCH (r {id: $id})<-[d:DISABLED]-()
|
|
SET r.disabled = false
|
|
DELETE d
|
|
`
|
|
const session = driver.session()
|
|
const res = await session.run(cypher, { id })
|
|
session.close()
|
|
return Boolean(res)
|
|
}
|
|
}
|
|
}
|