Skip to content

Commit 9089ced

Browse files
committed
Better approach for default config
#fix #26
1 parent 0ace9aa commit 9089ced

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

postgresql.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ module.exports = function (RED) {
9999
node.query = config.query;
100100
node.split = config.split;
101101
node.rowsPerMsg = config.rowsPerMsg;
102-
node.config = RED.nodes.getNode(config.postgreSQLConfig);
102+
node.config = RED.nodes.getNode(config.postgreSQLConfig) || {
103+
pgPool: {
104+
totalCount: 0,
105+
},
106+
};
103107

104108
// Declare the ability of this node to provide ticks upstream for back-pressure
105109
node.tickProvider = true;
@@ -128,7 +132,7 @@ module.exports = function (RED) {
128132
let fill = 'grey';
129133
if (hasError) {
130134
fill = 'red';
131-
} else if (nbQueue <= 0 || !node.config.pgPool) {
135+
} else if (nbQueue <= 0) {
132136
fill = 'blue';
133137
} else if (nbQueue <= node.config.pgPool.totalCount) {
134138
fill = 'green';
@@ -137,7 +141,7 @@ module.exports = function (RED) {
137141
}
138142
node.status({
139143
fill,
140-
shape: hasError || !node.config.pgPool || nbQueue > node.config.pgPool.totalCount ? 'ring' : 'dot',
144+
shape: hasError || nbQueue > node.config.pgPool.totalCount ? 'ring' : 'dot',
141145
text: 'Queue: ' + nbQueue + (hasError ? ' Error!' : ''),
142146
});
143147
hasError = false;

0 commit comments

Comments
 (0)