mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
64 lines
2.3 KiB
HTML
64 lines
2.3 KiB
HTML
|
|
<script type="text/x-red" data-template-name="sqlitedb">
|
|
<div class="form-row">
|
|
<label for="node-config-input-db"><i class="fa fa-database"></i> Database</label>
|
|
<input type="text" id="node-config-input-db" placeholder="/tmp/sqlite">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('sqlitedb',{
|
|
category: 'config',
|
|
defaults: {
|
|
db: {value:"",required:true}
|
|
},
|
|
label: function() {
|
|
return this.db;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
|
|
<script type="text/x-red" data-template-name="sqlite">
|
|
<div class="form-row">
|
|
<label for="node-input-mydb"><i class="fa fa-database"></i> Database</label>
|
|
<input type="text" id="node-input-mydb">
|
|
</div>
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="sqlite">
|
|
<p>Allows basic access to a Sqlite database.</p>
|
|
<p>This node uses the <b>db.all</b> operation against the configured database. This does allow INSERTS, UPDATES and DELETES.
|
|
By its very nature it is SQL injection... so <i>be careful out there...</i></p>
|
|
<p><code>msg.topic</code> must hold the <i>query</i> for the database, and the result is returned in <code>msg.payload</code>.</p>
|
|
<p><code>msg.payload</code> can contain an array of values to bind to the topic.</p>
|
|
<p>Typically the returned payload will be an array of the result rows, (or an error).</p>
|
|
<p>The reconnect timeout in milliseconds can be changed by adding a line to <b>settings.js</b>
|
|
<pre>sqliteReconnectTime: 20000,</pre></p>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('sqlite',{
|
|
category: 'storage-input',
|
|
color:"#e97b00",
|
|
defaults: {
|
|
mydb: {type:"sqlitedb",required:true},
|
|
name: {value:""}
|
|
},
|
|
inputs:1,
|
|
outputs:1,
|
|
icon: "sqlite.png",
|
|
label: function() {
|
|
var dbNode = RED.nodes.node(this.mydb);
|
|
return this.name||(dbNode?dbNode.label():"sqlite");
|
|
},
|
|
labelStyle: function() {
|
|
return this.name?"node_label_italic":"";
|
|
}
|
|
});
|
|
</script>
|