For the 4.6 mongo aggregation docs on operator expressions, $in is mentioned and $not is mentioned but $nin is not mentioned.
https://docs.mongodb.com/v3.6/meta/aggregation-quick-reference/#agg-quick-ref-operator-expressions
$nin is explained for find and update in the docs.
https://docs.mongodb.com/manual/reference/operator/query/nin/
On jira for those logged in with access solutions are given using $nin with aggregation examples.
https://jira.mongodb.org/browse/SERVER-9030?focusedCommentId=294125&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-294125
But is $nin a valid operation, because it is not in the docs.
Or as an alternative will $in and $not, combined return documents with $nin functionality?
example:
db.collection("collection).aggregate([
{
$match {
'fieldname': {$nin: ['10', '20','2']}
}
}
])
alternative example,
db.collection("collection).aggregate([
{
$project: {
"store location" : "$location",
"has bananas" : { $in: [ "bananas", "$in_stock" ] }
}
}
{
$match: { "has bananas": 0 }
}
])
wow, when I was writing the example I think I figured it out.
If I want $nin I should just match where $in returns false.
Hopefully, there is still reason to post the question as it provided me with confusion and may have confused others.
regards, Michael Dimmitt