Skip to content

Commit 7c1f931

Browse files
committed
fix to preserve original msg fields on out node
1 parent bffc6e2 commit 7c1f931

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

77-cloudant-cf.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,23 @@ module.exports = function(RED) {
231231

232232
if (node.search === "_id_") {
233233
var id = msg.payload;
234-
db.get(id, sendDocumentOnPayload);
234+
db.get(id, function(err, body) {
235+
sendDocumentOnPayload(err, body, msg);
236+
});
235237
}
236238
else if (node.search === "_idx_") {
237239
var query = { q: msg.payload };
238-
db.search(node.design, node.index, query, sendDocumentOnPayload);
240+
db.search(node.design, node.index, query, function(err, body) {
241+
sendDocumentOnPayload(err, body, msg);
242+
});
239243
}
240244
});
241245
}
242246

243-
function sendDocumentOnPayload(err, body) {
247+
function sendDocumentOnPayload(err, body, msg) {
244248
if (!err) {
245-
node.send({ payload: body });
249+
msg.payload = body;
250+
node.send(msg);
246251
} else {
247252
if (err.description === "missing") {
248253
node.warn("Document '" + node.payloadIn+ "' not found in database '" +

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "node-red-node-cf-cloudant",
3-
"version" : "0.2.3",
3+
"version" : "0.2.4",
44
"description" : "A Node-RED node to access a Cloudant database on Bluemix",
55
"dependencies" : {
66
"nano" : "5.10.0"

0 commit comments

Comments
 (0)