# FindOne on node mongodb-2 to no avail

**URL:** <https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333>\
**Category:** General\
**Created:** [28 August 2021 18:45 UTC](https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333 "2021-08-28T18:45:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [28 August 2021 18:45 UTC](https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333/1 "2021-08-28T18:45:59Z")

</div>

I'm trying to use the mongodb-2 node to retrieve a saved information and for that I'm using the example of the mongodb-2 node page but without success...

In the terminal the query returns me the desired information as shown in the print below:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/3896fed8d17ce57932d7a69b92f07ae61fae71bc.png)

This is the flow I'm following as a model:

```auto
[{"id":"68165b4c.c9e594","type":"function","z":"78f389d4.a3e498","name":"findOne","func":" var newMsg = {};\nnewMsg.operation = 'findOne';\nnewMsg.payload = { 'name' : 'Pete1' , 'names' : 'Pete2' };\nnewMsg.projection = { 'name' : 1 , '_id' : 0 };\nreturn newMsg;","outputs":1,"x":332,"y":220,"wires":[["a5eff45.9a49908"]]}]

```

This is what I'm trying to use to retrieve the information:

```auto
[{"id":"528be7f.6a30d18","type":"function","z":"ca7a266a.c18118","name":"findOne","func":" var newMsg = {};\nnewMsg.operation = 'findOne';\nnewMsg.payload = { 'timestamp' : '/28\\/08\\/2021/' };\n//newMsg.projection = { 'timestamp' : 1 };\nreturn newMsg;","outputs":1,"noerr":0,"x":760,"y":240,"wires":[["3f71662.230999a"]]}]

```

Could someone help me how do I fix this request to mongo?

I thank you and I'm waiting!

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [28 August 2021 19:22 UTC](https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333/2 "2021-08-28T19:22:44Z")

</div>

Hello Alisson ..

The mongodb2 node hasnt been updated for more that 4 years.  
and other people have reported some problems with it also.

Can you try unistalling it and installing the more recent **node-red-node-mongodb**

> **[node-red-node-mongodb](https://flows.nodered.org/node/node-red-node-mongodb)**
>
> Node-RED nodes to talk to a Mongo database

ps. you can only have one version installed .. so make sure to uninstall the older one first

* * *

With `newMsg.payload = { 'timestamp' : '/28\/08\/2021/' };`  
are you trying to use a regular expression pattern ?

try without the quotes

`newMsg.payload = { 'timestamp' : /28\/08\/2021/ };`

or

`newMsg.payload = { 'timestamp': { $regex: '28\/08\/2021' } }`

---

<div class="post-metadata">

**Author:** ![omalisson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omalisson/32/32797_2.png) [@omalisson](https://discourse.nodered.org/u/omalisson)\
**Post date:** [29 August 2021 23:38 UTC](https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333/3 "2021-08-29T23:38:49Z")

</div>

Hello UnborN! Goodnight!

I removed the single quotes and it worked!!

Thanks for your help as it solved my problem!!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a0346e0b2109d8951348c79b3bd5f3cc4e1c58c.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 September 2021 23:39 UTC](https://discourse.nodered.org/t/findone-on-node-mongodb-2-to-no-avail/50333/4 "2021-09-12T23:39:19Z")

</div>

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