Look the following documents in a contacts collection on MongoDB 3.4:
{
"_id" : ObjectId("58f045526320ef24fc61fdb2"),
"name" : "John Doe",
"tags" : [
{
"name": "tagA",
"created_at": ISODate("2017-01-27T10:30:00Z")
},
{
"name": "tagB",
"created_at": ISODate("2017-01-28T13:30:00Z")
}
],
},
{
"_id" : ObjectId("58f045526320ef24fc61fdb3"),
"name" : "Johnny Doe",
"tags" : [
{
"name": "tagA",
"created_at": ISODate("2016-12-21T19:30:00Z")
},
{
"name": "tagC",
"created_at": ISODate("2017-01-28T13:30:00Z")
}
],
}
.
.
.
Is there any query using only find method (nor aggregate framework, nor $where) that can return:
- The contacts who have all the following tags: [tagA, tagC]
- The contacts who don't have all of these tags: [tagC, tagD]
- The contacts with all tags in 2017
Thanks in advanced