mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #470 from anna2130/msg-property-overrides
Message properties overriding set node properties
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
<script type="text/x-red" data-help-name="file">
|
||||
<p>Writes <b>msg.payload</b> to the file specified, e.g. to create a log.</p>
|
||||
<p>The filename can be overridden by the <b>msg.filename</b> property of the incoming message.</p>
|
||||
<p>The filename can be configured in the node, if left blank it should be set in an incoming message on <b>msg.filename</b>.</p>
|
||||
<p>A newline is added to every message. But this can be turned off if required, for example, to allow binary files to be written.</p>
|
||||
<p>The default behaviour is to append to the file. This can be changed to overwrite the file each time, for example if you want to output a "static" web page or report.</p>
|
||||
<p>If a <b>msg.delete</b> property exists then the file will be deleted instead.</p>
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
<script type="text/x-red" data-help-name="file in">
|
||||
<p>Reads the specified file and sends the content as <b>msg.payload</b>, and the filename as <b>msg.filename</b>.</p>
|
||||
<p>The filename can be overridden by the <b>msg.filename</b> property of the incoming message.</p>
|
||||
<p>The filename can be configured in the node, if left blank it should be set in an incoming message on <b>msg.filename</b>.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@@ -25,7 +25,15 @@ module.exports = function(RED) {
|
||||
this.overwriteFile = n.overwriteFile;
|
||||
var node = this;
|
||||
this.on("input",function(msg) {
|
||||
var filename = msg.filename || this.filename;
|
||||
var filename;
|
||||
if (msg.filename) {
|
||||
if (n.filename) {
|
||||
node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
filename = msg.filename;
|
||||
} else {
|
||||
filename = this.filename;
|
||||
}
|
||||
if (filename === "") {
|
||||
node.warn('No filename specified');
|
||||
} else if (msg.hasOwnProperty('delete')) {
|
||||
@@ -72,7 +80,15 @@ module.exports = function(RED) {
|
||||
options['encoding'] = this.format;
|
||||
}
|
||||
this.on("input",function(msg) {
|
||||
var filename = msg.filename || this.filename;
|
||||
var filename;
|
||||
if (msg.filename) {
|
||||
if (n.filename) {
|
||||
node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props");
|
||||
}
|
||||
filename = msg.filename;
|
||||
} else {
|
||||
filename = this.filename;
|
||||
}
|
||||
if (filename === "") {
|
||||
node.warn('No filename specified');
|
||||
} else {
|
||||
@@ -92,4 +108,4 @@ module.exports = function(RED) {
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("file in",FileInNode);
|
||||
}
|
||||
};
|
||||
|
@@ -200,7 +200,7 @@
|
||||
<p>Find queries a collection using the <b>msg.payload</b> as the query statement as per the .find() function. Optionally, you may also (via a function) set a <b>msg.projection</b> object to constrain the returned fields, a <b>msg.sort</b> object and a <b>msg.limit</b> object.</p>
|
||||
<p>Count returns a count of the number of documents in a collection or matching a query using the <b>msg.payload</b> as the query statement.</p>
|
||||
<p>Aggregate provides access to the aggregation pipeline using the <b>msg.payload</b> as the pipeline array.</p>
|
||||
<p>You can override the collection the method is performed on by setting <b>msg.collection</b> to the desired collection name.</p>
|
||||
<p>You can either set the collection method in the node config or on <b>msg.collection</b>. Setting it in the node will override <b>msg.collection</b>.</p>
|
||||
<p>See the <a href="http://docs.mongodb.org/manual/reference/method/db.collection.find/" target="new"><i>MongoDB collection methods docs</i></a> for examples.</p>
|
||||
<p>The result is returned in <b>msg.payload</b>.</p>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user