ozomer / node-red-contrib-mongodb2

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

Projection document using mongodb3? #25

Closed axelhult closed 6 years ago

axelhult commented 6 years ago

Hi!

Im switching from the mongodb2- to mongodb3 node. Using the following code to return specific fields (x_data) from my documents:

msg.collection="data"; msg.operation="findOne"; msg.payload=[{_id: "id123"}, {x_data: 1}];

Works as expected using the mongodb2-node, but the same code returns the whole document when using the mongodb3 node.

Any thoughts on this? Thanks

axelhult commented 6 years ago

... adding "fields" before parameters solved it:

msg.collection="data"; msg.operation="findOne"; msg.payload=[{_id: "id123"}, {"fields":{x_data: 1}}]

pelagaggi commented 5 years ago

hello, I am not being able to use a MongoDB auto-generated _id, is there any way to use "_id": 'ObjectId("myID")' as an argument?