1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #354 from hindessm/redis-string-fix

Make more effort to stringify sensibly when storing in redis.
This commit is contained in:
Nick O'Leary 2014-08-28 14:15:53 +01:00
commit e09ac859d3

View File

@ -83,6 +83,13 @@ module.exports = function(RED) {
var k = this.key || msg.topic;
if (k) {
if (this.structtype == "string") {
if (Buffer.isBuffer(msg.payload)) {
msg.payload = msg.payload.toString();
} else if (typeof msg.payload === "object") {
msg.payload = JSON.stringify(msg.payload);
} else if (typeof msg.payload !== "string") {
msg.payload = ""+msg.payload;
}
this.client.set(k,msg.payload);
} else if (this.structtype == "hash") {
var r = hashFieldRE.exec(msg.payload);