Split msg.payload and insert in mongodb in key value format

227 views
Skip to first unread message

Rahul Prajapati

unread,
May 23, 2015, 6:01:16 AM5/23/15
to node...@googlegroups.com
Hi 
I want to split msg.payload.

when i am inserting the data its store in mongodb like bellow:
 "payload" : "email=rahul%40gmail.com&password=we12"

But i want to store data using flow in bellow format
 "email" : "="de...@gmail.com","password"="demo"


Nicholas O'Leary

unread,
May 23, 2015, 6:23:13 AM5/23/15
to node...@googlegroups.com

Given this is similar to Manpreet's question and we've seen a similar pattern of question asking from you both, I'm guessing this is related to some school assignment you've both been given.

Id be interested to know if I'm right about that, and if so, what the course is.

As for your question, it looks like email/pword are being passed in over an http request. If that is the case, look at the http in node documentation - it links to the express docs which explains how you can access the query parameters already parsed under msg.req.query.

From there you can construct whatever object you want.

If you want to stick to your string parsing way of doing it, that is basic JavaScript and not specific to node-red. I suggest you go do some research on stackoverflow for how to do basic string splitting.

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julian Knight

unread,
May 23, 2015, 7:21:53 AM5/23/15
to node...@googlegroups.com
And it would be poor of me not to comment that storing the password in this way is a very bad idea given that you are passing it over the wire in clear text and storing it in your database also in clear text.

So make sure you only ever use an account that you don't care about and that will be deleted later.
Reply all
Reply to author
Forward
0 new messages