2

I have to read data from a cloudant db. The resultant msg.payload has values like these:

[{"_id":"0de4df1286119588b8529a01ce7ae88c","_rev":"2-6702cf5c73c76536d403caaae37f9f99","payload":{"direction":"out","count":"-1","timestamp":"2016-10-06T13:25:24.262Z"}},{"_id":"1cf44a5241cc413a21920b069942851c","_rev":"1-f0f2271864d39b5ca633fe284590ae99","payload":{"direction":"out","count":"-1","timestamp":"2016-10-06T14:38:11.920Z"}},{"_id":"970049cb8ec6e3853d50f65f520ad385","_rev":"1-f7642fc0eab3938388138e04ce1d2c26","payload":{"direction":"IN","count":"1","timestamp":"2016-10-06T13:25:16.286Z"}}]

I want to select all the _id from the above payload.

I want to print only the _id from the payload using the debug node I tried using msg.payload._id but it is not working. It shows the result as just "{}"

ralphearle
  • 1,696
  • 13
  • 18

1 Answers1

1

The problem is the payload object is an array object (which makes sense for a result set returned from a database query)

You need to include the array index in the debug node output filter

.payload[0]._id

This will give _id from the first entry in the array

hardillb
  • 54,545
  • 11
  • 67
  • 105