I have a collection of documents similar to this:
{
Name : "Name1",
Product : 1012,
Titles : [ {
Id: 5,
Title: "FirstTitle"
},
{
Id: 75,
Title: "SecondTitle"
}
},
{
Name : "Name1",
Product : 2014,
Titles : [ {
Id: 5,
Title: "FirstTitle"
},
{
Id: 75,
Title: "SecondTitle"
}
}
I'm matching by the Name with an aggregate to get all documents with the same name. Then if all matches have the exact same set of Titles, I want that set.
{
Name : "Name1,
TitlesVaries : false
Titles : [ {
Id: 5,
Title: "FirstTitle"
},
{
Id: 75,
Title: "SecondTitle"
}
}
If they are different I want to know that.
{
Name : "Name1"
TitlesVaries : true
Titles : null
}
I'm having trouble comparing the set/array titles for each document to see if they are all exactly the same after I've don't my aggregate/match. Some documents can have empty/null arrays of Titles and if they are all empty/null that's a match