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