title: Checking for the existence of an element in array full of objects
body: <p>I have an array of likes which includes the ids of the users that have liked the post (this is originally a mongoose model). I want to check if the user's id is in the array.</p>
  <pre><code>const likes =  
  [
      {
          &quot;user&quot;: &quot;6283986e931a243f64eb063e&quot;
      },
      {
          &quot;user&quot;: &quot;6283986e931a243f64eb0123s&quot;
      },
  ]
  
  const user = &quot;6283986e931a243f64eb063e&quot;;
  
  const hasBeenLiked = Object.values(likes).includes(user);
  
  console.log(hasBeenLiked) //returns false
  </code></pre>
  <p>Obviously i cannot check this way. I am aware that i can do this with loop, but i want more lightweight approach (if possible).</p>
  <p>The orignal code is:</p>
  <pre><code>const hasBeenLiked = Object.values(article.likes).includes(req.headers.user);
  </code></pre>
  <p>If this is not possible without the use of loops is there a mongoose command for this?</p>