Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified object is returned on next query even when not stored persistently #8

Open
konacurrents opened this issue Jan 29, 2022 · 0 comments

Comments

@konacurrents
Copy link

konacurrents commented Jan 29, 2022

I posted to the node-red forum about an issue I'm having with persistence.

Basically, after a dataOut retrieval, the msg.payload contains the JSON data. I then modify a parameter, such as msg.payload.password, to return the query to the user (but with the password blanked out). This payload is NOT stored.

The next dataIn retrieval for the same query returns the modified in-memory version, instead of going to the values stored in the persistent file.

I found that RED.util.cloneMessage(msg.payload) makes a copy and I can modify that to send on in my flow.

msg.payload = RED.util.cloneMessage(msg.payload);
msg.payload.password = "";
msg.payload.guestPassword = "";

Without the clone message, the next retrieval has a JSON object with an empty password.

For me this wasn't obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant