9774d9b1e0
Thank you for including a Neo4j example! This PR rewrites the Cypher queries using a [pattern comprehension](https://neo4j.com/docs/cypher-manual/current/syntax/lists/#cypher-pattern-comprehension) which will make them more performant and removes the need for the `collect(DISTINCT ...)` step.
23 lines
727 B
JavaScript
23 lines
727 B
JavaScript
import neo4j from 'neo4j-driver'
|
|
|
|
let driver
|
|
|
|
const defaultOptions = {
|
|
uri: process.env.NEO4J_URI,
|
|
username: process.env.NEO4J_USER,
|
|
password: process.env.NEO4J_PASSWORD,
|
|
}
|
|
|
|
export default function getDriver() {
|
|
const { uri, username, password } = defaultOptions
|
|
if (!driver) {
|
|
// Note: There is a disparity between Neo4j (Java) Integers and JavaScript integers
|
|
// I have used `disableLosslessIntegers` to remove the need to call `.toNumber()` on each integer value
|
|
// For more info see: https://github.com/neo4j/neo4j-javascript-driver/#numbers-and-the-integer-type
|
|
driver = neo4j.driver(uri, neo4j.auth.basic(username, password), {
|
|
disableLosslessIntegers: true,
|
|
})
|
|
}
|
|
|
|
return driver
|
|
}
|