title: MongoDB: How to check is user in array
body: <p>I've got a problem. I'm creating a question to MongoDB:</p>
  
  <pre class="lang-js prettyprint-override"><code>const team: TeamDocument = await Team.findOne({ members: payload.id, name })
  </code></pre>
  
  <p>The problem is, <code>members</code> is an array of objects:</p>
  
  <pre class="lang-js prettyprint-override"><code>members: [{
      name: { type: Schema.Types.ObjectId, ref: 'User' },
      role: String
  }]
  </code></pre>
  
  <p>So when I create ask, it showes an error:</p>
  
  <pre><code>UnhandledPromiseRejectionWarning: ObjectParameterError: Parameter "obj" to Document() must be an object, got 5e88984b1478de32f43289e8
  </code></pre>
  
  <p>How can I repair this, so it will check if the members array has an object which contains an id provided in payload?</p>