Favor transaction functions even for seeds

This commit is contained in:
mattwr18 2019-12-11 19:38:39 +01:00
parent 53791c83e8
commit 6903a6cc71

View File

@ -29,10 +29,16 @@ const factories = {
export const cleanDatabase = async (options = {}) => {
const { driver = getDriver() } = options
const cypher = 'MATCH (n) DETACH DELETE n'
const session = driver.session()
try {
return await session.run(cypher)
await session.writeTransaction(transaction => {
return transaction.run(
`
MATCH (everything)
DETACH DELETE everything
`,
)
})
} finally {
session.close()
}