如何执行“NOT IN"在不使用 $nin 的情况下在 mongodb 中查询? [英] How to perform a "NOT IN" query in mongodb without using $nin?

查看:175
本文介绍了如何执行“NOT IN"在不使用 $nin 的情况下在 mongodb 中查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 mongodb 中使用 $nin 的替代方案.众所周知,我们也可以通过执行OR"查询来实现IN"查询操作.

I need an alternative to $nin in mongodb. As we know, we can achieve the "IN" query operation by performing "OR" query as well.

同样,如何在不使用 $nin 的情况下在 mongodb 中实现 "NOT IN" 功能?在 mongodb 中使用 $nin 以获得完全相同的结果的替代方法是什么?

In the same way, how can I achieve "NOT IN" functionality in mongodb without using $nin ? What are the alternatives to using $nin in mongodb to acheive exactly same results ?

推荐答案

我发现有一个运算符 $nor 正好完成了这个功能.它作为 $or 的否定.

I found that there is a operator $nor which exactly does this function. It works as the negation of $or.

这篇关于如何执行“NOT IN"在不使用 $nin 的情况下在 mongodb 中查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆