Make msg.limit and msg.skip optional as per the README (#303)

This commit is contained in:
Ben Hardill 2017-04-19 11:11:47 +01:00 committed by Dave Conway-Jones
parent f2cc2bb321
commit c17aac3b66
1 changed files with 4 additions and 0 deletions

View File

@ -206,10 +206,14 @@ module.exports = function(RED) {
var limit = msg.limit;
if (typeof limit === "string" && !isNaN(limit)) {
limit = Number(limit);
} else if (typeof limit === "undefined") {
limit = 0;
}
var skip = msg.skip;
if (typeof skip === "string" && !isNaN(skip)) {
skip = Number(skip);
} else if (typeof skip === "undefined") {
skip = 0;
}
coll.find(selector,msg.projection).sort(msg.sort).limit(limit).skip(skip).toArray(function(err, items) {