diff --git a/package.json b/package.json
index 2a7d07d..03ae1b8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-postgresql",
- "version": "0.15.4",
+ "version": "0.15.5",
"description": "Node-RED node for PostgreSQL, supporting parameters, split, back-pressure",
"author": {
"name": "Alexandre Alapetite",
diff --git a/postgresql.html b/postgresql.html
index 39ce99e..2bf71a2 100644
--- a/postgresql.html
+++ b/postgresql.html
@@ -49,7 +49,6 @@
-
-
@@ -153,22 +151,13 @@
connectionTimeoutFieldType: {
value: 'num',
},
- user: {
- value: '',
- },
- userFieldType: {
- value: 'str',
- },
- password: {
- value: '',
- },
- passwordFieldType: {
- // TODO: https://nodered.org/docs/creating-nodes/credentials
- value: 'str',
- },
+ },
+ credentials: {
+ user: { type: 'text' },
+ password: { type: 'password' },
},
label: function () {
- return this.name || this.user + '@' + this.host + ':' + this.port + '/' + this.database;
+ return this.name || this.host + ':' + this.port + '/' + this.database;
},
labelStyle: function () {
return this.name ? 'node_label_italic' : '';
@@ -213,17 +202,6 @@
types: ['bool', 'global', 'env', 'json'],
typeField: $('#node-config-input-sslFieldType'),
});
- $('#node-config-input-user').typedInput({
- default: 'str',
- types: ['str', 'global', 'env'],
- typeField: $('#node-config-input-userFieldType'),
- });
- $('#node-config-input-password')
- .typedInput({
- default: 'str',
- types: ['str', 'global', 'env'],
- typeField: $('#node-config-input-passwordFieldType'),
- });
$('#node-config-input-applicationName').typedInput({
default: 'str',
types: ['str', 'global', 'env'],
@@ -234,11 +212,6 @@
types: ['num', 'global'],
typeField: $('#node-config-input-maxFieldType'),
});
- $('#node-config-input-lin').typedInput({
- default: 'num',
- types: ['num', 'global'],
- typeField: $('#node-config-input-linFieldType'),
- });
$('#node-config-input-idle').typedInput({
default: 'num',
types: ['num', 'global'],
diff --git a/postgresql.js b/postgresql.js
index 7375641..3dd2361 100644
--- a/postgresql.js
+++ b/postgresql.js
@@ -54,6 +54,7 @@ module.exports = function (RED) {
function PostgreSQLConfigNode(n) {
const node = this;
RED.nodes.createNode(node, n);
+
node.name = n.name;
node.host = n.host;
node.hostFieldType = n.hostFieldType;
@@ -69,16 +70,12 @@ module.exports = function (RED) {
node.maxFieldType = n.maxFieldType;
node.idle = n.idle;
node.idleFieldType = n.idleFieldType;
- node.user = n.user;
- node.userFieldType = n.userFieldType;
- node.password = n.password;
- node.passwordFieldType = n.passwordFieldType;
node.connectionTimeout = n.connectionTimeout;
node.connectionTimeoutFieldType = n.connectionTimeoutFieldType;
this.pgPool = new Pool({
- user: getField(node, n.userFieldType, n.user),
- password: getField(node, n.passwordFieldType, n.password),
+ user: node.credentials.user,
+ password: node.credentials.password,
host: getField(node, n.hostFieldType, n.host),
port: getField(node, n.portFieldType, n.port),
database: getField(node, n.databaseFieldType, n.database),
@@ -88,12 +85,18 @@ module.exports = function (RED) {
idleTimeoutMillis: getField(node, n.idleFieldType, n.idle),
connectionTimeoutMillis: getField(node, n.connectionTimeoutFieldType, n.connectionTimeout),
});
+
this.pgPool.on('error', (err, _) => {
node.error(err.message);
});
}
- RED.nodes.registerType('postgreSQLConfig', PostgreSQLConfigNode);
+ RED.nodes.registerType('postgreSQLConfig', PostgreSQLConfigNode, {
+ credentials: {
+ user: { type: 'text' },
+ password: { type: 'password' },
+ },
+ });
function PostgreSQLNode(config) {
const node = this;