forked from neo4j-graph-examples/network-management
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
28 lines (24 loc) · 741 Bytes
/
Copy pathexample.js
File metadata and controls
28 lines (24 loc) · 741 Bytes
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
// npm install --save neo4j-driver
// node example.js
const neo4j = require('neo4j-driver');
const driver = neo4j.driver('bolt://<HOST>:<BOLTPORT>',
neo4j.auth.basic('<USERNAME>', '<PASSWORD>'),
{/* encrypted: 'ENCRYPTION_OFF' */});
const query =
`
MATCH (dc:DataCenter {location: $location})-[:CONTAINS]->(r:Router)-[:ROUTES]->(i:Interface)
RETURN i.ip as ip
`;
const params = {"location": "Iceland"};
const session = driver.session({database:"neo4j"});
session.run(query, params)
.then((result) => {
result.records.forEach((record) => {
console.log(record.get('ip'));
});
session.close();
driver.close();
})
.catch((error) => {
console.error(error);
});