I came across a query that I couldn't make. The use case I was told is that I would need to find if there is any faulty data where a book doesn't contain a title. Books happen to be a array. So I need to find out if all books in the books array must contain a title field.
I have only came up with the query for the first element like so
{"books": {$exists: true, $not: {$size: 0}}, "books.0.title": {$exists: false}}. How do I do it for all elements?
Document:
{
id: oid(abc123..)
name: John Doe
books: [
{
title: MyBook1
}
{
title: MyBook2
}
...
]
}