1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle strings for limit/skip args to mongo node

This commit is contained in:
Nick O'Leary 2015-02-20 20:02:25 +00:00
parent 1c86908b90
commit 4dc21c43fa

View File

@ -184,7 +184,16 @@ module.exports = function(RED) {
if (node.operation === "find") { if (node.operation === "find") {
msg.projection = msg.projection || {}; msg.projection = msg.projection || {};
var selector = ensureValidSelectorObject(msg.payload); var selector = ensureValidSelectorObject(msg.payload);
coll.find(selector,msg.projection).sort(msg.sort).limit(msg.limit).skip(msg.skip).toArray(function(err, items) { var limit = msg.limit;
if (typeof limit === "string" && !isNaN(limit)) {
limit = Number(limit);
}
var skip = msg.skip;
if (typeof skip === "string" && !isNaN(skip)) {
skip = Number(skip);
}
coll.find(selector,msg.projection).sort(msg.sort).limit(limit).skip(skip).toArray(function(err, items) {
if (err) { if (err) {
node.error(err); node.error(err);
} else { } else {