Skip to content

Instantly share code, notes, and snippets.

@ozomer

ozomer/README.md Secret

Created March 28, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozomer/b44ff06a385743b7bbf7 to your computer and use it in GitHub Desktop.
Save ozomer/b44ff06a385743b7bbf7 to your computer and use it in GitHub Desktop.
node-red-contrib-mongodb2 example

Example for node-red-contrib-mongodb2

Finds a document and update its counter instantly using findOneAndUpdate.

[{"id":"f98d7079.06729","type":"function","name":"build operation parameters: filter, update","func":"var filter = msg.payload;\nif (\"string\" == typeof filter) {\n filter = JSON.parse(filter);\n}\n\nmsg.payload = [\n filter,\n {\n \"$inc\": {\n \"counter\": 1\n }\n }\n];\n\nreturn msg;\n","outputs":1,"x":332,"y":220,"z":"a2b633a9.5d49d","wires":[["58eb3ed.fa714c"]]},{"id":"58eb3ed.fa714c","type":"mongodb2 in","service":"_ext_","configNode":"","name":"","collection":"mycollection","operation":"findOneAndUpdate","x":438.3333435058594,"y":148.77780151367188,"z":"a2b633a9.5d49d","wires":[["1b847e1.fe47b82"]]},{"id":"2d6fecfe.d29014","type":"inject","name":"Inject filter","topic":"","payload":"{\"_id\":\"mydocument\"}","payloadType":"string","repeat":"","crontab":"","once":false,"x":97.5,"y":220,"z":"a2b633a9.5d49d","wires":[["f98d7079.06729"]]},{"id":"1b847e1.fe47b82","type":"debug","name":"","active":true,"console":"false","complete":"false","x":672,"y":221,"z":"a2b633a9.5d49d","wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment