Search code examples
mongodbnode-red

find the mongodb document if a key-value paired is matched from nested document using node red function node


i have a mongodb collection named "Device_Records", using node-red i would like to extract all the documents that satisfy a mongo query.Till now i used mongodb node , drag and drop the mongo node and select "find" from the operation selector. But this does not work when the document is of a nested document.  here is the screenshort more over i want to use msg.operation in the node-red function node so that i can write dynamic query. i would like to get all the documents that match "device_id":66 from this collection.since Condition is a key which is a array of objets,am confused about the query :(


Solution

  • You can use the dot notation in your query: { 'Condition.device_id': 66 }: