• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How I can find if string exists inside mongodb Array

Resolved: How I can find if string exists inside mongodb Array

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am trying to find document based on profileID in MongoDB. I want to check if string postid exists in array or not. How I can do that? I tried $all.
Mongo data:
Trying to find if post1 exists in array:

Answer:

If you want to check if a string exists in an array field you can simply do:
Docs
Also you might notice i have made the whole query as the first parameter. The second parameter is usually the callback to run, once the query has executed.

If you have better answer, please add a comment about this, thank you!

javascript mongodb node.js
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to give rank on datetime column group by another column with userid in it

24/03/2023

Resolved: Passing 2 functions in onChange in react

24/03/2023

Resolved: Why doesn’t stringstream consume output during hex formatting?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.