mongoose/mongodb querying for records without a related record <p>I have two mongoose models. Let's call one model foo and the second model bar. Bar records have a related foo record and an email address. I want my api to be passed an email address and return a list of foo records that do not have a bar record created with that email address. How would I go about doing this with mongoose?</p> <p>I know I could write this query with SQL but ive been trying to learn a no sql db, hence mongo.</p> <p>Here is an example. I have 2 foo records and 2 bar records:</p> <p>foos:</p> <pre><code>{name:"first foo"} {name:"second foo"} </code></pre> <p>and my bar records:</p> <pre><code>{ email:"requestEmail@example.com, foo_id:first_foo._id } { email:"someOther@example.com, foo_id:second_foo._id } </code></pre> <p>The request to my api would come in with email: requestEmail@example.com. In this case, I would want to return the second foo (and any other foo records) because first foo has a bar record with the email in the request. </p>