title: Mongodb findone document in array by object id
body: <p>Can I get only 1 photo by <code>objectid</code>? I only need to get 1 Image detail from 1 post by photo but what i get is all photo of post.</p>
  
  <p><strong>this is my db structure</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/rJktD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rJktD.png" alt="enter image description here"></a></p>
  
  <p><strong>and this is my code looks like:</strong></p>
  
  <pre><code> Post.findOne({
    $and: [
      { photo: { $elemMatch: { _id: id } } }       ]
  }).exec((err, post) =&gt; {
    if (err) {
      return res.status(400).json({ error: err });
    }
    req.post = post;
    console.log(req.post);
    next();
  });
  </code></pre>
  
  <p>what i get in req.post is only [].</p>
  
  <p>Thanks in advance</p>