mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
fix formatting and merge issues
This commit is contained in:
parent
44e0fb61c8
commit
a600ef03d6
@ -55,8 +55,8 @@
|
|||||||
name: {value: ""}
|
name: {value: ""}
|
||||||
},
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
user: { type: "text" },
|
user: {type: "text"},
|
||||||
password: { type: "password" }
|
password: {type: "password"}
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.name || this.db + "@" + this.hostname;
|
return this.name || this.db + "@" + this.hostname;
|
||||||
@ -190,7 +190,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#node-input-collection").change(function () {
|
$("#node-input-collection").change(function () {
|
||||||
if ($("#node-input-collection").val() === "") {
|
if($("#node-input-collection").val() === "") {
|
||||||
$("#node-warning").show();
|
$("#node-warning").show();
|
||||||
} else {
|
} else {
|
||||||
$("#node-warning").hide();
|
$("#node-warning").hide();
|
||||||
@ -202,23 +202,23 @@
|
|||||||
category: 'storage-output',
|
category: 'storage-output',
|
||||||
color: "rgb(218, 196, 180)",
|
color: "rgb(218, 196, 180)",
|
||||||
defaults: {
|
defaults: {
|
||||||
mongodb: { type: "mongodb", required: true },
|
mongodb: {type: "mongodb", required: true},
|
||||||
name: { value: "" },
|
name: {value: ""},
|
||||||
collection: { value: "" },
|
collection: {value: ""},
|
||||||
payonly: { value: false },
|
payonly: {value: false},
|
||||||
upsert: { value: false },
|
upsert: {value: false},
|
||||||
multi: { value: false },
|
multi: {value: false},
|
||||||
operation: { value: "store" }
|
operation: {value: "store"}
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 0,
|
outputs: 0,
|
||||||
icon: "mongodb.png",
|
icon: "mongodb.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
label: function () {
|
label: function() {
|
||||||
var mongoNode = RED.nodes.node(this.mongodb);
|
var mongoNode = RED.nodes.node(this.mongodb);
|
||||||
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
||||||
},
|
},
|
||||||
labelStyle: function () {
|
labelStyle: function() {
|
||||||
return this.name ? "node_label_italic" : "";
|
return this.name ? "node_label_italic" : "";
|
||||||
},
|
},
|
||||||
oneditprepare: oneditprepare
|
oneditprepare: oneditprepare
|
||||||
@ -270,21 +270,21 @@
|
|||||||
category: 'storage-input',
|
category: 'storage-input',
|
||||||
color: "rgb(218, 196, 180)",
|
color: "rgb(218, 196, 180)",
|
||||||
defaults: {
|
defaults: {
|
||||||
mongodb: { type: "mongodb", required: true },
|
mongodb: {type: "mongodb", required: true},
|
||||||
name: { value: "" },
|
name: {value: ""},
|
||||||
collection: { value: "" },
|
collection: {value: ""},
|
||||||
operation: { value: "find" }
|
operation: {value: "find"}
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
icon: "mongodb.png",
|
icon: "mongodb.png",
|
||||||
label: function () {
|
label: function() {
|
||||||
var mongoNode = RED.nodes.node(this.mongodb);
|
var mongoNode = RED.nodes.node(this.mongodb);
|
||||||
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
||||||
},
|
},
|
||||||
labelStyle: function () {
|
labelStyle: function() {
|
||||||
return this.name ? "node_label_italic" : "";
|
return this.name ? "node_label_italic" : "";
|
||||||
},
|
},
|
||||||
oneditprepare: oneditprepare
|
oneditprepare: oneditprepare
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,7 +7,7 @@ module.exports = function(RED) {
|
|||||||
var MongoClient = mongo.MongoClient;
|
var MongoClient = mongo.MongoClient;
|
||||||
|
|
||||||
function MongoNode(n) {
|
function MongoNode(n) {
|
||||||
RED.nodes.createNode(this, n);
|
RED.nodes.createNode(this,n);
|
||||||
this.hostname = n.hostname;
|
this.hostname = n.hostname;
|
||||||
this.port = n.port;
|
this.port = n.port;
|
||||||
this.db = n.db;
|
this.db = n.db;
|
||||||
@ -46,10 +46,10 @@ module.exports = function(RED) {
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("mongodb", MongoNode, {
|
RED.nodes.registerType("mongodb",MongoNode,{
|
||||||
credentials: {
|
credentials: {
|
||||||
user: { type: "text" },
|
user: {type:"text"},
|
||||||
password: { type: "password" }
|
password: {type: "password"}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MongoOutNode(n) {
|
function MongoOutNode(n) {
|
||||||
RED.nodes.createNode(this, n);
|
RED.nodes.createNode(this,n);
|
||||||
this.collection = n.collection;
|
this.collection = n.collection;
|
||||||
this.mongodb = n.mongodb;
|
this.mongodb = n.mongodb;
|
||||||
this.payonly = n.payonly || false;
|
this.payonly = n.payonly || false;
|
||||||
@ -92,13 +92,13 @@ module.exports = function(RED) {
|
|||||||
if (node.collection) {
|
if (node.collection) {
|
||||||
coll = db.collection(node.collection);
|
coll = db.collection(node.collection);
|
||||||
}
|
}
|
||||||
node.on("input", function (msg) {
|
node.on("input",function(msg) {
|
||||||
if (!node.collection) {
|
if (!node.collection) {
|
||||||
if (msg.collection) {
|
if (msg.collection) {
|
||||||
coll = db.collection(msg.collection);
|
coll = db.collection(msg.collection);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.error(RED._("mongodb.errors.nocollection"), msg);
|
node.error(RED._("mongodb.errors.nocollection"),msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,17 +124,17 @@ module.exports = function(RED) {
|
|||||||
if (node.mongoConfig) { connectToDB(); }
|
if (node.mongoConfig) { connectToDB(); }
|
||||||
else { node.error(RED._("mongodb.errors.missingconfig")); }
|
else { node.error(RED._("mongodb.errors.missingconfig")); }
|
||||||
|
|
||||||
node.on("close", function () {
|
node.on("close", function() {
|
||||||
node.status({});
|
node.status({});
|
||||||
if (node.tout) { clearTimeout(node.tout); }
|
if (node.tout) { clearTimeout(node.tout); }
|
||||||
if (node.clientDb) { node.clientDb.close(); }
|
if (node.clientDb) { node.clientDb.close(); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("mongodb out", MongoOutNode);
|
RED.nodes.registerType("mongodb out",MongoOutNode);
|
||||||
|
|
||||||
|
|
||||||
function MongoInNode(n) {
|
function MongoInNode(n) {
|
||||||
RED.nodes.createNode(this, n);
|
RED.nodes.createNode(this,n);
|
||||||
this.collection = n.collection;
|
this.collection = n.collection;
|
||||||
this.mongodb = n.mongodb;
|
this.mongodb = n.mongodb;
|
||||||
this.payonly = n.payonly || false;
|
this.payonly = n.payonly || false;
|
||||||
@ -142,7 +142,7 @@ module.exports = function(RED) {
|
|||||||
this.multi = n.multi || false;
|
this.multi = n.multi || false;
|
||||||
this.operation = n.operation || "find";
|
this.operation = n.operation || "find";
|
||||||
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
||||||
this.status({ fill: "grey", shape: "ring", text: RED._("mongodb.status.connecting") });
|
this.status({fill:"grey",shape:"ring",text: RED._("mongodb.status.connecting")});
|
||||||
var node = this;
|
var node = this;
|
||||||
var noerror = true;
|
var noerror = true;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ module.exports = function(RED) {
|
|||||||
var db = client.db();
|
var db = client.db();
|
||||||
noerror = true;
|
noerror = true;
|
||||||
var coll;
|
var coll;
|
||||||
node.on("input", function (msg) {
|
node.on("input", function(msg) {
|
||||||
if (!node.collection) {
|
if (!node.collection) {
|
||||||
if (msg.collection) {
|
if (msg.collection) {
|
||||||
coll = db.collection(msg.collection);
|
coll = db.collection(msg.collection);
|
||||||
@ -194,7 +194,7 @@ module.exports = function(RED) {
|
|||||||
coll.find(selector).project(msg.projection).sort(msg.sort).limit(limit).skip(skip).toArray(function(err, items) {
|
coll.find(selector).project(msg.projection).sort(msg.sort).limit(limit).skip(skip).toArray(function(err, items) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
> }
|
}
|
||||||
else {
|
else {
|
||||||
msg.payload = items;
|
msg.payload = items;
|
||||||
delete msg.projection;
|
delete msg.projection;
|
||||||
@ -207,7 +207,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else if (node.operation === "count") {
|
else if (node.operation === "count") {
|
||||||
selector = ensureValidSelectorObject(msg.payload);
|
selector = ensureValidSelectorObject(msg.payload);
|
||||||
coll.count(selector, function (err, count) {
|
coll.count(selector, function(err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ module.exports = function(RED) {
|
|||||||
if (node.mongoConfig) { connectToDB(); }
|
if (node.mongoConfig) { connectToDB(); }
|
||||||
else { node.error(RED._("mongodb.errors.missingconfig")); }
|
else { node.error(RED._("mongodb.errors.missingconfig")); }
|
||||||
|
|
||||||
node.on("close", function () {
|
node.on("close", function() {
|
||||||
node.status({});
|
node.status({});
|
||||||
if (node.tout) { clearTimeout(node.tout); }
|
if (node.tout) { clearTimeout(node.tout); }
|
||||||
if (node.clientDb) { node.clientDb.close(); }
|
if (node.clientDb) { node.clientDb.close(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user