UNPKG

node-red-contrib-objectid

Version:

Node-RED node to create an Object-Id for mongodb operations.

42 lines (34 loc) 1.42 kB
<script type="text/javascript"> RED.nodes.registerType('objectid',{ category: 'function', color: '#3FADB5', defaults: { name: { value: "" }, selectedProperty: { value: "_id" } }, inputs:1, outputs:1, icon: "inject.png", label: function() { return this.name || `${this.selectedProperty}` || 'ObjectID'; } }); </script> <script type="text/x-red" data-template-name="objectid"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-selectedProperty"><i class="fa fa-list"></i> Property</label> <input type="text" id="node-input-selectedProperty" placeholder="_id" /> </div> </script> <script type="text/x-red" data-help-name="objectid"> <p>This Node-Red node is to create an Object-Id for mongodb write operations from JSON inputs.</p></br> <p>The selected property in `msg.payload` will be converted to an Object-Id, you can input a 24 char hexstring via `_id` property and it creates an Object-Id.</p> <p>If there is none of the property the node will add that property with an Object-Id.</p> <p>For example: <code>msg.payload._id = "572dbc06f307c8682045c55c"</code></p> <p>If the target property value is null/false/0, a random Object-Id is created.</p> </script>