|
[{"id":"b6e503ad.b7d59","type":"inject","z":"b4aeef03.c16228","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":88.20001220703125,"y":414.2000274658203,"wires":[["7ee1b81d.caf718"]]},{"id":"7ee1b81d.caf718","type":"http request","z":"b4aeef03.c16228","name":"List all Cloudant DBs","method":"GET","ret":"obj","url":"https://<Replace with correct value>/_all_dbs","x":341.2000732421875,"y":411,"wires":[["f1683a52.70d1f8"]]},{"id":"f1683a52.70d1f8","type":"function","z":"b4aeef03.c16228","name":"Parse out Device DBs and Query them","func":"var dbs = msg.payload;\n\n//I am only interested in DBs with iotp in the name\nvar regex = /iotp/;\n//Then I need to exclude the configuration db\nvar regex2 = /configuration/;\n\n//Loop though the DBs calling the query one by one.\n//Be cautious of this if you have a lot of DBs\nfor (var i=0; i < dbs.length ; i++){\n //check if it has iotp in the name\n if (regex.test(dbs[i])){\n //check if it has configuration in the name\n if (regex2.test(dbs[i]) === false){\n msg.db=dbs[i];\n //async call with just the dbname\n node.send({db:dbs[i]});\n }\n }\n}\n\n","outputs":1,"noerr":0,"x":470.800048828125,"y":492.60003662109375,"wires":[["ec8900e2.314ec","82ecb617.fbb918"]]},{"id":"82ecb617.fbb918","type":"http request","z":"b4aeef03.c16228","name":"Query DB by-deviceID for 1 Doc in each DB","method":"GET","ret":"obj","url":"https://<Replace with correct value>/{{{db}}}/_design/iotp/_view/by-deviceId?limit=1","x":873.5,"y":492.4000244140625,"wires":[["6a6f8c01.53af24"]]}] |