How to find in mongodb

hi how find in mongodb data base
exp I need find this UUID : "a506e376-b38b-473d-a7aa-a70652cdacb5"
or this id: next and equal :
how it
Untitled
I use this msg but not work

msg.find = {"UUID":{ $in:"a506e376-b38b-473d-a7aa-a70652cdacb5"}};
return msg;

but return all document

Untitled

Which mongo node are you using?

Does its sidebar help say to put the query in msg.find? Off the top of my head, I'm not aware of a node that uses msg.find (but I haven't tried them all). Most nodes would expect the query to be in msg.topic or msg.payload.

1 Like
msg.projection = {"UUID":{ $in:"a506e376-b38b-473d-a7aa-a70652cdacb5"}, "ack":1};
return msg;

error return

"MongoError: Unsupported projection option: UUID: { $in: "a506e376-b38b-473d-a7aa-a70652cdacb5" }"

That node expects the find options to be in msg.payload.

1 Like

so I use this

msg.payload = {_id: {$gt: ObjectId("5ea4995f4a677c4e68acb899" )}}

now error return:

"ReferenceError: ObjectId is not defined (line 4, col 27)"

when used this

msg.payload = {UUID: {$in:"a506e376-b38b-473d-a7aa-a70652cdacb5" }}

return error

"MongoError: $in needs an array"

if used without $in

msg.payload = {"UUID":"a506e376-b38b-473d-a7aa-a70652cdacb5"}
{
"_msgid":"42d8881b.1fdbc8",
"topic":"",
"payload":[
{
"_id":"5ea4995f4a677c4e68acb89a",
"topic":"ps30kv/RTU",
"payload":"[{\"topic\":\"ACK-RTU\",\"payload\":\"switch dp\"}]",
"qos":0,
"retain":false,
"_msgid":"e45548ec.cfe208",
"time":"Sat Apr 25 2020 21:11:11 GMT+0100 (GMT+01:00)",
"ack":true,
"UUID":"a506e376-b38b-473d-a7aa-a70652cdacb5"
}
]
}

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.