-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
executable file
·41 lines (35 loc) · 958 Bytes
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
import neo4j from "neo4j-driver";
import loadCypher from "./loadCypher.js";
import { runReadQueries } from "./runCypherQueries.js";
const [
,
,
$1,
$2 = "neo4j://localhost:7687",
$3 = "neo4j",
$4 = "1234",
] = process.argv;
const driver = neo4j.driver($2, neo4j.auth.basic($3, $4));
const session = driver.session();
async function main() {
try {
const serverInfo = await driver.verifyConnectivity();
console.log(serverInfo);
const cypherExerciseQueries = loadCypher(`./exercises/${$1}.cypher`);
const results = await runReadQueries(session, cypherExerciseQueries);
results.forEach((result) => {
if (result.records && Array.isArray(result.records)) {
result.records.forEach((r) =>
console.log(JSON.stringify(r, undefined, 2))
);
}
});
} catch (err) {
console.error(err);
} finally {
await session.close();
}
await driver.close();
}
main();