{"action":"created","issue":{"url":"https://api.github.com/repos/node-red/node-red/issues/628","labels_url":"https://api.github.com/repos/node-red/node-red/issues/628/labels{/name}","comments_url":"https://api.github.com/repos/node-red/node-red/issues/628/comments","events_url":"https://api.github.com/repos/node-red/node-red/issues/628/events","html_url":"https://github.com/node-red/node-red/pull/628","id":70402091,"number":628,"title":"preserves msg variables when firing messages in batch with 'find'-action","user":{"login":"coderofsalvation","id":180068,"avatar_url":"https://avatars.githubusercontent.com/u/180068?v=3","gravatar_id":"","url":"https://api.github.com/users/coderofsalvation","html_url":"https://github.com/coderofsalvation","followers_url":"https://api.github.com/users/coderofsalvation/followers","following_url":"https://api.github.com/users/coderofsalvation/following{/other_user}","gists_url":"https://api.github.com/users/coderofsalvation/gists{/gist_id}","starred_url":"https://api.github.com/users/coderofsalvation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coderofsalvation/subscriptions","organizations_url":"https://api.github.com/users/coderofsalvation/orgs","repos_url":"https://api.github.com/users/coderofsalvation/repos","events_url":"https://api.github.com/users/coderofsalvation/events{/privacy}","received_events_url":"https://api.github.com/users/coderofsalvation/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T12:38:35Z","updated_at":"2015-04-23T12:40:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/node-red/node-red/pulls/628","html_url":"https://github.com/node-red/node-red/pull/628","diff_url":"https://github.com/node-red/node-red/pull/628.diff","patch_url":"https://github.com/node-red/node-red/pull/628.patch"},"body":"usecase\r\n=======\r\nI use the mongodb-in node to check whether an document exist, and if not, add it to mongodb.\r\nThis takes up 2 mongodb nodes to do the job.\r\nSo lets assume this coffeescript node:\r\n\r\n    msg.collection = \"foo\"\r\n    msg.limit = 1\r\n    msg.skip = 1\r\n    msg.item       = { \"foo\": \"bar1\", \"flop\": true }\r\n    msg.payload = { \"foo\": msg.item.foo }\r\n\r\nNow Imagine 10 variations of this message (with msg.item values bar1...bar10) which are sent sequentially to the mongodb-in node, using a node-red-contrib-splitter node.\r\nThe reason to store msg.item, is because msg.payload will be deleted by the mongodb-node.\r\nBy doing so, we can use the msg.item as a payload for storing it into a mongodb later on.\r\nThis has always worked with <  node-red v0.10.6\r\n\r\n## The issue\r\nNow imagine firing 10 variations of this message to a mongodb-in node sequentially .\r\nNow for some weird reason (which I could not discover in the coffeescript or splitter node), it seems that the coll.find() of mongodb-node will return 10 msg objects with msg.item set to the *last item* (so 10 times a msg with msg.item set to 'bar10').\r\n\r\n## The fix\r\n\r\nThis seems to do it\r\n"},"comment":{"url":"https://api.github.com/repos/node-red/node-red/issues/comments/95573051","html_url":"https://github.com/node-red/node-red/pull/628#issuecomment-95573051","issue_url":"https://api.github.com/repos/node-red/node-red/issues/628","id":95573051,"user":{"login":"knolleary","id":51083,"avatar_url":"https://avatars.githubusercontent.com/u/51083?v=3","gravatar_id":"","url":"https://api.github.com/users/knolleary","html_url":"https://github.com/knolleary","followers_url":"https://api.github.com/users/knolleary/followers","following_url":"https://api.github.com/users/knolleary/following{/other_user}","gists_url":"https://api.github.com/users/knolleary/gists{/gist_id}","starred_url":"https://api.github.com/users/knolleary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knolleary/subscriptions","organizations_url":"https://api.github.com/users/knolleary/orgs","repos_url":"https://api.github.com/users/knolleary/repos","events_url":"https://api.github.com/users/knolleary/events{/privacy}","received_events_url":"https://api.github.com/users/knolleary/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T12:40:36Z","updated_at":"2015-04-23T12:40:36Z","body":"Hi,\r\n\r\nplease can you have a read of our [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md).\r\n\r\nNew features etc should be discussed on the mailing list before pull-requests are raised.\r\n\r\nWe also require a signed contribution license agreement in place before we can accept these things. I though we had had one from you before, but I can't find any record of it and I may be mixing you up with someone else.\r\n\r\nNick"}}