Tiny performance improvement

This commit is contained in:
Robert Schäfer 2019-03-06 17:21:49 +01:00
parent f40a67b7a8
commit 8072939458
2 changed files with 10 additions and 15 deletions

View File

@ -17,8 +17,8 @@ export default {
enable: async (object, params, { user, driver }) => {
const { resource: { id } } = params
const cypher = `
MATCH (p {id: $id})<-[d:DISABLED]-()
SET p.disabled = false
MATCH (r {id: $id})<-[d:DISABLED]-()
SET r.disabled = false
DELETE d
`
const session = driver.session()

View File

@ -92,12 +92,10 @@ describe('disable', () => {
setup.createResource = async () => {
await factory.create('User', { id: 'u45', email: 'commenter@example.org', password: '1234' })
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
await factory.create('Post', {
id: 'p3'
})
await factory.create('Comment', {
id: 'c47'
})
await Promise.all([
factory.create('Post', { id: 'p3' }),
factory.create('Comment', { id: 'c47' })
])
await Promise.all([
factory.relate('Comment', 'Author', { from: 'u45', to: 'c47' }),
factory.relate('Comment', 'Post', { from: 'c47', to: 'p3' })
@ -251,13 +249,10 @@ describe('enable', () => {
setup.createResource = async () => {
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
await factory.create('Post', {
id: 'p9' // that's the ID we will look for
})
await factory.create('Comment', {
id: 'c456'
})
await Promise.all([
factory.create('Post', { id: 'p9' }),
factory.create('Comment', { id: 'c456' })
])
await Promise.all([
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' }),
factory.relate('Comment', 'Post', { from: 'c456', to: 'p9' })