title: How to find a json object in a json array mongoose
body: <p>I have an array of json objects like such</p>
  
  <pre><code>[{firstname: "Tom", lastname: "Smith"}, {firstname: "Bob", lastname: "Smith"}]
  </code></pre>
  
  <p>I would like to find whether an element in that array is located in a User object with field names that also contains an array of json objects.</p>
  
  <p>An example of the User object is</p>
  
  <pre><code>{ "names": [{firstname: "joe", "lastname":"smith"}, {"firstname": "john", "lastname":"doe"}]}
  </code></pre>
  
  <p>and I would like to find out if any of those names objects are contained in an array of random length called list2 of format below</p>
  
  <pre><code>[{firstname: "Tom", lastname: "Smith"}, {firstname: "Bob", lastname: "Smith"}, {firstname: "Joe", lastname: "Smith"}, {firstname: "Jordan", lastname: "Smith"}, {firstname: "John", lastname: "Smith"}, {firstname: "Bill", lastname: "Smith"}]
  </code></pre>
  
  <p>How would I create a mongoose query to do that?</p>
  
  <p>Thanks!</p>