I have the following schema:
var ParagraphsSchema = new Schema({
originalText: String,
suggestions: [{
text: String,
is_approved: { type: Boolean, default: false }
}]
});
And the task is to get paragraphs where all suggestions are not approved (suggestion.is_approved = false)
I have already tried things like
Paragraph.find({ 'suggestions.is_approved': { $all: [false] })
Paragraph.find({'suggestions.is_approved': { $all: {"$elemMatch": false} } })
but none of them seem to work.
The obvious way would be to add "is_approved" property to Paragraph schema, but that would make data redundant and make code harder to maintain, that's why I would like to avoid it.
I'm using MongoDB==3.6.2 and Mongoose==5.0.3