-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathexample.js
More file actions
28 lines (24 loc) · 770 Bytes
/
example.js
File metadata and controls
28 lines (24 loc) · 770 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('neo4j://<HOST>:<BOLTPORT>',
neo4j.auth.basic('<USERNAME>', '<PASSWORD>'),
{/* encrypted: 'ENCRYPTION_OFF' */});
const query =
`
MATCH (m:Movie {title:$movie})<-[:RATED]-(u:User)-[:RATED]->(rec:Movie)
RETURN distinct rec.title AS recommendation LIMIT 20
`;
const params = {"movie": "Crimson Tide"};
const session = driver.session({database:"neo4j"});
session.run(query, params)
.then((result) => {
result.records.forEach((record) => {
console.log(record.get('recommendation'));
});
session.close();
driver.close();
})
.catch((error) => {
console.error(error);
});