|
1 |
| -<script type="text/x-red" data-template-name="mongodb-config"> |
| 1 | +<script type="text/x-red" data-template-name="mongodb"> |
2 | 2 | <div class="form-row">
|
3 | 3 | <label for="node-config-input-hostname"><i class="fa fa-bookmark"></i> <span data-i18n="mongodb.label.host"></span></label>
|
4 | 4 | <input class="input-append-left" type="text" id="node-config-input-hostname" placeholder="localhost" style="width: 40%;" >
|
|
24 | 24 | </script>
|
25 | 25 |
|
26 | 26 | <script type="text/javascript">
|
27 |
| - RED.nodes.registerType('mongodb-config', { |
| 27 | + RED.nodes.registerType('mongodb', { |
28 | 28 | category: 'config',
|
29 | 29 | color: "rgb(218, 196, 180)",
|
30 | 30 | defaults: {
|
|
44 | 44 | </script>
|
45 | 45 |
|
46 | 46 |
|
47 |
| -<script type="text/x-red" data-template-name="mongodb"> |
| 47 | +<script type="text/x-red" data-template-name="mongodb out"> |
48 | 48 | <div class="form-row">
|
49 | 49 | <label for="node-input-mongodb"><i class="fa fa-bookmark"></i> <span data-i18n="mongodb.label.server"></span></label>
|
50 | 50 | <input type="text" id="node-input-mongodb">
|
|
56 | 56 | <div class="form-row">
|
57 | 57 | <label for="node-input-operation"><i class="fa fa-wrench"></i> <span data-i18n="mongodb.label.operation"></span></label>
|
58 | 58 | <select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;">
|
59 |
| - <option value="find" data-i18n="mongodb.operation.find"></option> |
60 |
| - <option value="count" data-i18n="mongodb.operation.count"></option> |
61 |
| - <option value="aggregate" data-i18n="mongodb.operation.aggregate"></option> |
62 |
| - <option value="store" data-i18n="mongodb.operation.save"></option> |
| 59 | + <option value="store" data-i18n="mongodb.operation.save"></option> |
63 | 60 | <option value="insert" data-i18n="mongodb.operation.insert"></option>
|
64 | 61 | <option value="update" data-i18n="mongodb.operation.update"></option>
|
65 | 62 | <option value="delete" data-i18n="mongodb.operation.remove"></option>
|
|
70 | 67 | <input type="checkbox" id="node-input-payonly" style="display: inline-block; width: auto; vertical-align: top;">
|
71 | 68 | <label for="node-input-payonly" style="width: 70%;"><span data-i18n="mongodb.label.onlystore"></span></label>
|
72 | 69 | </div>
|
73 |
| - <div class="form-row node-input-upsert"> |
| 70 | + <div class="form-row node-input-upsert"> |
74 | 71 | <label> </label>
|
75 | 72 | <input type="checkbox" id="node-input-upsert" style="display: inline-block; width: auto; vertical-align: top;">
|
76 | 73 | <label for="node-input-upsert" style="width: 70%;"><span data-i18n="mongodb.label.createnew"></span></label>
|
|
87 | 84 | <div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]mongodb.tip"></span></div>
|
88 | 85 | </script>
|
89 | 86 |
|
90 |
| -<script type="text/x-red" data-help-name="mongodb"> |
91 |
| - <p>A simple MongoDB node. Can manipulate a chosen collection.</p> |
92 |
| - |
93 |
| - <p>Find queries a collection using the <code>msg.payload</code> as the query statement as per the .find() function. |
94 |
| - Optionally, you may also set a <code>msg.projection</code> object (via a function) to constrain the returned |
95 |
| - fields. You can also set a <code>msg.sort</code> object, a <code>msg.limit</code> number and a <code>msg.skip</code> number.</p> |
96 |
| - |
97 |
| - <p>Count returns a count of the number of documents in a collection, or matches a query using the |
98 |
| - <code>msg.payload</code> as the query statement.</p> |
99 |
| - |
100 |
| - <p>Aggregate provides access to the aggregation pipeline using the <code>msg.payload</code> as the pipeline array.</p> |
101 |
| - |
102 |
| - |
103 |
| - <p>Save will update an existing object or insert a new object if one does not already exist.</p> |
104 |
| - |
105 |
| - <p>Insert will insert a new object.</p> |
106 |
| - |
107 |
| - <p>Update will modify an existing object or objects. The query to select objects to update uses <code>msg.query</code>, |
| 87 | +<script type="text/x-red" data-help-name="mongodb out"> |
| 88 | + <p>A simple MongoDB output node. Can save, insert, update and remove objects from a chosen collection.</p> |
| 89 | + <p>Save will update an existing object or insert a new object if one does not already exist.</p> |
| 90 | + <p>Insert will insert a new object.</p> |
| 91 | + <p>Save and insert either store <code>msg</code> or <code>msg.payload</code>.</p> |
| 92 | + <p>Update will modify an existing object or objects. The query to select objects to update uses <code>msg.query</code>, |
108 | 93 | and the update to the element uses <code>msg.payload</code>. If <code>msg.query._id</code> is
|
109 | 94 | a valid mongo ObjectId string it will be converted to an ObjectId type.</p>
|
110 | 95 | <p>Update can add an object if it does not exist or update multiple objects.</p>
|
111 | 96 | <p>Remove will remove objects that match the query passed in on <code>msg.payload</code>. A blank query will delete
|
112 |
| - <i>all of the objects</i> in the collection.</p> |
113 |
| - |
| 97 | + <i>all of the objects</i> in the collection.</p> |
114 | 98 | <p>You can either set the collection method in the node config or on <code>msg.collection</code>. Setting it in the
|
115 |
| - node will override <code>msg.collection</code>.</p> |
116 |
| - |
117 |
| - <p>See the <a href="http://docs.mongodb.org/manual/reference/method/db.collection.find/" target="new"><i>MongoDB |
118 |
| - collection methods docs</i></a> for examples.</p> |
119 |
| - <p>The result is returned in <code>msg.payload</code>.</p> |
120 |
| - |
| 99 | + node will override <code>msg.collection</code>.</p> |
121 | 100 | <p>By default, MongoDB creates an <i>_id</i> property as the primary key, so repeated injections of the
|
122 |
| - same <code>msg</code> will result in many database entries.</p> |
123 |
| - |
| 101 | + same <code>msg</code> will result in many database entries.</p> |
124 | 102 | <p>If this is NOT the desired behaviour, i.e., you want repeated entries to overwrite, then you must set
|
125 |
| - the <code>msg._id</code> property to be a constant by the use of a previous function node.</p> |
126 |
| - |
| 103 | + the <code>msg._id</code> property to be a constant by the use of a previous function node.</p> |
127 | 104 | <p>This could be a unique constant or you could create one based on some other msg property.</p>
|
128 | 105 | <p>Currently we do not limit or cap the collection size, however this may well change.</p>
|
129 | 106 | </script>
|
130 | 107 |
|
131 | 108 | <script type="text/javascript">
|
132 | 109 |
|
133 |
| - |
134 |
| - |
135 | 110 | function oneditprepare() {
|
136 | 111 | $("#node-input-operation").change(function () {
|
137 | 112 | var id = $("#node-input-operation option:selected").val();
|
|
156 | 131 | });
|
157 | 132 | }
|
158 | 133 |
|
159 |
| - RED.nodes.registerType('mongodb', { |
160 |
| - category: 'storage', |
| 134 | + RED.nodes.registerType('mongodb out', { |
| 135 | + category: 'storage-output', |
161 | 136 | color: "rgb(218, 196, 180)",
|
162 | 137 | defaults: {
|
163 |
| - mongodb: { type: "mongodb-config", required: true }, |
| 138 | + mongodb: { type: "mongodb", required: true }, |
164 | 139 | name: { value: "" },
|
165 | 140 | collection: { value: "" },
|
166 | 141 | payonly: { value: false },
|
167 |
| - operation: { value: "find" }, |
168 | 142 | upsert: { value: false },
|
169 |
| - multi: { value: false } |
| 143 | + multi: { value: false }, |
| 144 | + operation: { value: "store" } |
| 145 | + }, |
| 146 | + inputs: 1, |
| 147 | + outputs: 0, |
| 148 | + icon: "mongodb.png", |
| 149 | + align: "right", |
| 150 | + label: function () { |
| 151 | + var mongoNode = RED.nodes.node(this.mongodb); |
| 152 | + return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb"); |
| 153 | + }, |
| 154 | + labelStyle: function () { |
| 155 | + return this.name ? "node_label_italic" : ""; |
| 156 | + }, |
| 157 | + oneditprepare: oneditprepare |
| 158 | + }); |
| 159 | +</script> |
| 160 | + |
| 161 | + |
| 162 | +<script type="text/x-red" data-template-name="mongodb in"> |
| 163 | + <div class="form-row"> |
| 164 | + <label for="node-input-mongodb"><i class="fa fa-bookmark"></i> <span data-i18n="mongodb.label.server"></span></label> |
| 165 | + <input type="text" id="node-input-mongodb"> |
| 166 | + </div> |
| 167 | + <div class="form-row"> |
| 168 | + <label for="node-input-collection"><i class="fa fa-briefcase"></i> <span data-i18n="mongodb.label.collection"></span></label> |
| 169 | + <input type="text" id="node-input-collection"> |
| 170 | + </div> |
| 171 | + <div class="form-row"> |
| 172 | + <label for="node-input-operation"><i class="fa fa-wrench"></i> <span data-i18n="mongodb.label.operation"></span></label> |
| 173 | + <select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;"> |
| 174 | + <option value="find" data-i18n="mongodb.operation.find"></option> |
| 175 | + <option value="count" data-i18n="mongodb.operation.count"></option> |
| 176 | + <option value="aggregate" data-i18n="mongodb.operation.aggregate"></option> |
| 177 | + </select> |
| 178 | + </div> |
| 179 | + <div class="form-row"> |
| 180 | + <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label> |
| 181 | + <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name"> |
| 182 | + </div> |
| 183 | + <div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]mongodb.tip"></span></div> |
| 184 | +</script> |
| 185 | + |
| 186 | +<script type="text/x-red" data-help-name="mongodb in"> |
| 187 | + <p>Calls a MongoDB collection method based on the selected operator.</p> |
| 188 | + <p>Find queries a collection using the <code>msg.payload</code> as the query statement as per the .find() function. |
| 189 | + Optionally, you may also set a <code>msg.projection</code> object (via a function) to constrain the returned |
| 190 | + fields. You can also set a <code>msg.sort</code> object, a <code>msg.limit</code> number and a <code>msg.skip</code> number.</p> |
| 191 | + <p>Count returns a count of the number of documents in a collection, or matches a query using the |
| 192 | + <code>msg.payload</code> as the query statement.</p> |
| 193 | + <p>Aggregate provides access to the aggregation pipeline using the <code>msg.payload</code> as the pipeline array.</p> |
| 194 | + <p>You can either set the collection method in the node config or on <code>msg.collection</code>. Setting it in |
| 195 | + the node will override <code>msg.collection</code>.</p> |
| 196 | + <p>See the <a href="http://docs.mongodb.org/manual/reference/method/db.collection.find/" target="new"><i>MongoDB |
| 197 | + collection methods docs</i></a> for examples.</p> |
| 198 | + <p>The result is returned in <code>msg.payload</code>.</p> |
| 199 | +</script> |
| 200 | + |
| 201 | +<script type="text/javascript"> |
| 202 | + |
| 203 | + RED.nodes.registerType('mongodb in', { |
| 204 | + category: 'storage-input', |
| 205 | + color: "rgb(218, 196, 180)", |
| 206 | + defaults: { |
| 207 | + mongodb: { type: "mongodb", required: true }, |
| 208 | + name: { value: "" }, |
| 209 | + collection: { value: "" }, |
| 210 | + operation: { value: "find" } |
170 | 211 | },
|
171 | 212 | inputs: 1,
|
172 | 213 | outputs: 1,
|
|
0 commit comments