Public
Edited
Jul 1, 2023
3 forks
16 stars
Neo4j Driver for JavaScript
Insert cell
Insert cell
Insert cell
neo4j = require("neo4j-driver@4.4.1")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof database = text({
title: "DATABASE:",
description: "Database to use",
value: "movies"
})
Insert cell
Insert cell
driver = neo4j.driver(
scheme + "://" + host + ":" + port,
neo4j.auth.basic(user, password)
)
Insert cell
Insert cell
Insert cell
async function runQuery(statement) {
const session = driver.session({ database: database });
let results;

await session
.run(statement)
.then((r) => {
results = r.records.map((d) => d.toObject());
session.close();
})
.catch((error) => {
results = error.message;
});

return results;
}
Insert cell
Insert cell
persons = await runQuery(
"MATCH (p:Person) return p.name as name ORDER BY name"
).catch(() => [])
Insert cell
movies = await runQuery ('MATCH (m:Movie) return m.title as title ORDER BY title')
Insert cell
roles = await runQuery(
"MATCH (p:Person)-[r:ACTED_IN]->(m:Movie) return {source: p.name, roles:r.roles, target: m.title} AS role"
)
Insert cell
allNodes = await runQuery("MATCH (n) RETURN n")
Insert cell
allPaths = await runQuery("MATCH p=()-[]->() RETURN p")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { ForceGraph } from "@d3/disjoint-force-directed-graph"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more