[英]Documentation? and is $nin in mongodb Aggregation or not?
對於關於運算符表達式的4.6 mongo聚合文檔,提到$ in並提到$ not,但是沒有提及$ nin。 https://docs.mongodb.com/v3.6/meta/aggregation-quick-reference/#agg-quick-ref-operator-expressions
$ nin在文檔中說明了查找和更新的方法。 https://docs.mongodb.com/manual/reference/operator/query/nin/
在jira上,使用$ nin和聚合示例給出使用訪問解決方案登錄的用戶。 https://jira.mongodb.org/browse/SERVER-9030?focusedCommentId=294125&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-294125
但是$ nin是有效的操作,因為它不在文檔中。 或者將$ in和$ not結合使用具有$ nin功能的退貨單嗎?
例:
db.collection("collection).aggregate([
{
$match {
'fieldname': {$nin: ['10', '20','2']}
}
}
])
替代示例
db.collection("collection).aggregate([
{
$project: {
"store location" : "$location",
"has bananas" : { $in: [ "bananas", "$in_stock" ] }
}
}
{
$match: { "has bananas": 0 }
}
])
哇,當我編寫示例時,我想我已經弄明白了。 如果我想要$ nin,我應該匹配$ in返回false的地方。
希望仍然有理由發布問題,因為它使我感到困惑,並可能使其他人感到困惑。 問候,邁克爾·迪米特(Michael Dimmitt)
db.collection("collection).aggregate([
{
$project: {
"store location" : "$location",
"has bananas" : { $in: [ "bananas", "$in_stock" ] }
}
}
{
$match: { "has bananas": 0 }
}
])
哇,當我編寫示例時,我想我已經弄明白了。
如果我想要$ nin,我應該匹配$ in返回false的地方。
希望仍然有理由發布問題,因為它使我感到困惑,並可能使其他人感到困惑。
如果該解決方案不正確並且可以證明,我將正確的解決方案標記為答案。 問候,邁克爾·迪米特(Michael Dimmitt) https://docs.mongodb.com/v3.6/reference/operator/aggregation/in/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.