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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more