ozomer / node-red-contrib-mongodb2

MongoDB driver node for Node-RED
Apache License 2.0
15 stars 19 forks source link

find.toArray returning an object of objects instead of an array #37

Open duartegarin opened 5 years ago

duartegarin commented 5 years ago

As the title says, find.toArray returning an object of objects instead of an array. Is this by design?

rcpehls commented 5 years ago

I have the same problem with node-red-contrib-mongodb3 but using node-red-contrib-mongodb2 return an array.

node-red-contrib-mongodb3 return {0: object,1: object,2: object}

node-red-contrib-mongodb2 return [object, object, object]

nicolasC35 commented 5 years ago

Same pb. The problem was not present in 1.0.0 version. In addition, the count operation returns an empty object (no value)

ozomer commented 5 years ago

I'm sorry but I don't have time to work on this. We are no longer using Node-RED in my company so I don't have motivation to make that effort :sweat_smile: If any of you wants to send a Pull-Request that fixes the issue and test it, I'll accept it blindly.

haaslukas commented 3 years ago

a workaround would be to add a function node after the mongodb node and convert the object to an array within nodered: var obj = msg.payload obj = Object.keys(obj).map((key) => obj[key]); msg.payload = obj return msg;