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
Answer:If you want to check if a string exists in an array field you can simply do:
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!