Skip to content

Commit 76df045

Browse files
committed
changed npm module name
1 parent 44623d1 commit 76df045

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

neo4j.js

+46-34
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,58 @@ module.exports = function (RED) {
66
//console.log(`url = ${config.url}`);
77
const driver = neo4j.driver(config.url, neo4j.auth.basic(config.username, config.password));
88
const session = driver.session();
9-
10-
node.on('input', function (msg) {
11-
//console.log(`decoding QR data from ${msg.payload}`);
12-
var query = config.query || msg.query;
13-
let params = null;
14-
if(typeof(msg.params) === 'string') {
15-
params = JSON.parse(msg.params);
16-
} else {
17-
params = msg.params;
18-
}
19-
//console.log(`params: ${params}`);
20-
var scalar_result = {
21-
payload: null
22-
};
23-
const resultPromise = session.run(query, params);
24-
25-
var array_result = {
26-
payload: []
27-
}
28-
resultPromise.then(result => {
29-
session.close();
30-
if(result.records.length > 1) {
31-
result.records.forEach(function(item, index, array) {
32-
array_result.payload.push(item.get(0).properties);
33-
});
34-
//console.log(`array size: ${array_result.payload.length}`)
35-
node.send([null, array_result]);
9+
if (session) {
10+
node.status({
11+
fill: "green",
12+
shape: "dot",
13+
text: "node-red:common.status.connected"
14+
});
15+
node.on('input', function (msg) {
16+
//console.log(`decoding QR data from ${msg.payload}`);
17+
var query = config.query || msg.query;
18+
let params = null;
19+
if (typeof (msg.params) === 'string') {
20+
params = JSON.parse(msg.params);
3621
} else {
37-
scalar_result.payload = result.records[0].get(0).properties;
38-
//msg.payload = result.records;
39-
node.send([scalar_result, null]);
22+
params = msg.params;
23+
}
24+
//console.log(`params: ${params}`);
25+
var scalar_result = {
26+
payload: null
27+
};
28+
const resultPromise = session.run(query, params);
4029

30+
var array_result = {
31+
payload: []
4132
}
33+
resultPromise.then(result => {
34+
session.close();
35+
if (result.records.length > 1) {
36+
result.records.forEach(function (item, index, array) {
37+
array_result.payload.push(item.get(0).properties);
38+
});
39+
//console.log(`array size: ${array_result.payload.length}`)
40+
node.send([null, array_result]);
41+
} else {
42+
scalar_result.payload = result.records[0].get(0).properties;
43+
//msg.payload = result.records;
44+
node.send([scalar_result, null]);
45+
46+
}
47+
});
4248
});
43-
});
49+
} else {
50+
node.status({
51+
fill: "red",
52+
shape: "dot",
53+
text: "node-red:common.status.disconnected"
54+
});
55+
}
4456

45-
node.on('close', function() {
57+
node.on('close', function () {
4658
// tidy up any state
4759
driver.close();
4860
});
4961
}
50-
RED.nodes.registerType("nulli-neo4j", NulliNeo4j);
51-
}
62+
RED.nodes.registerType("node-red-contrib-nulli-neo4j", NulliNeo4j);
63+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"node-red": {
2525
"nodes": {
26-
"nulli-neo4j": "neo4j.js"
26+
"node-red-contrib-nulli-neo4j": "neo4j.js"
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)