Search code examples
mongodbnode-red

Node red MongoDB limit requires an integer


I am trying to set up a simple IoT temperature monitoring system. Node Red seemed like a good solution.

I've installed node red and mongodb on ubuntu 16.04. When I try to store data into a mongodb, It gets stored succesfulyy, however, when i try to get the data from my database, i get the following error on my debug tab: MongoError: limit requires an integer

Here are my nodes:

[{"id":"845a2d0f.f529f","type":"debug","z":"175fe64a.2e87ba","name":"","active":true,"console":"false","complete":"false","x":698,"y":118,"wires":[]},{"id":"37b967b4.5953a8","type":"http in","z":"175fe64a.2e87ba","name":"/iot request","url":"/iot","method":"get","swaggerDoc":"","x":229.9517059326172,"y":314.0511169433594,"wires":[["70d77b6c.c2f234"]]},{"id":"70d77b6c.c2f234","type":"mongodb in","z":"175fe64a.2e87ba","mongodb":"5b5bee5b.f2593","name":"retrieve hello","collection":"test","operation":"find","x":472.9545593261719,"y":356.5880432128906,"wires":[["3b3c5324.f2f78c"]]},{"id":"3b3c5324.f2f78c","type":"http response","z":"175fe64a.2e87ba","name":"show hello","x":760.960205078125,"y":311.91192626953125,"wires":[]},{"id":"ac92efad.22272","type":"mqtt in","z":"175fe64a.2e87ba","name":"get outtemp","topic":"/sensors/esp0/temp0","qos":"2","broker":"fd4c9ee3.0aa1a","x":193,"y":118,"wires":[["845a2d0f.f529f","63a9e917.39f568"]]},{"id":"63a9e917.39f568","type":"mongodb out","z":"175fe64a.2e87ba","mongodb":"5b5bee5b.f2593","name":"store temp","collection":"test","payonly":true,"upsert":false,"multi":false,"operation":"store","x":406,"y":219,"wires":[]},{"id":"5b5bee5b.f2593","type":"mongodb","z":"","hostname":"127.0.0.1","port":"27017","db":"testdb","name":""},{"id":"fd4c9ee3.0aa1a","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"200","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

I am a complete begginer with both node red an mongodb, have some experience with mqtt.

How can I fix this?


Solution

  • After being pointed to the right direction by knolleary, I found This post on the node-red mail list.

    So this is what I had to do:

    add a function before mongodb find block and enter in this function:

    msg.limit = 5;
    msg.skip = 0;
    return msg;