mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
mongodb node take a skip property so pagination can be achieved
This commit is contained in:
parent
9e4187d6a8
commit
f461b121e1
@ -197,7 +197,7 @@
|
||||
|
||||
<script type="text/x-red" data-help-name="mongodb in">
|
||||
<p>Calls a MongoDB collection method based on the selected operator.</p>
|
||||
<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>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, a <b>msg.limit</b> number and a <b>msg.skip</b> number.</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 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>
|
||||
|
@ -184,7 +184,7 @@ module.exports = function(RED) {
|
||||
if (node.operation === "find") {
|
||||
msg.projection = msg.projection || {};
|
||||
var selector = ensureValidSelectorObject(msg.payload);
|
||||
coll.find(selector,msg.projection).sort(msg.sort).limit(msg.limit).toArray(function(err, items) {
|
||||
coll.find(selector,msg.projection).sort(msg.sort).limit(msg.limit).skip(msg.skip).toArray(function(err, items) {
|
||||
if (err) {
|
||||
node.error(err);
|
||||
} else {
|
||||
@ -192,6 +192,7 @@ module.exports = function(RED) {
|
||||
delete msg.projection;
|
||||
delete msg.sort;
|
||||
delete msg.limit;
|
||||
delete msg.skip;
|
||||
node.send(msg);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user