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":[]}]

Flow Info

Created 9 years, 10 months ago
Updated 9 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x1)
  • inject (x1)
Other

Tags

  • mongodb
  • mongodb2
  • findOneAndUpdate
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option