Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB中查找不返回内容时如何检查_Mongodb - Fatal编程技术网

MongoDB中查找不返回内容时如何检查

MongoDB中查找不返回内容时如何检查,mongodb,Mongodb,Q1>如何检查a2在MongoDB交互shell中是否分配了任何内容 Q2>如何在Python 3中检查相同的内容 > db.c.remove() > db.c.insert( { x : 10} ) > a1 = db.c.findOne( {x : 100} ) null > a1 == null true > a2 = db.c.find( {x : 100} ) > 因为您的a2变量实际上是一个MongoCursor。 很多语言驱动程序都有这种方法

Q1>如何检查a2在MongoDB交互shell中是否分配了任何内容

Q2>如何在Python 3中检查相同的内容

> db.c.remove()
> db.c.insert( { x : 10} )
> a1 = db.c.findOne( {x : 100} )
null
> a1 == null
true
> a2 = db.c.find( {x : 100} )
>
因为您的a2变量实际上是一个MongoCursor。 很多语言驱动程序都有这种方法

提示:您可以使用variable.help()在mongo客户端命令行上实现一些功能


编辑关于Python:我不知道它到底是如何工作的,但是关于文档,Python驱动程序返回一个iterable元素。因此,它的方式可能与其他语言相同。

我完全忘了它是DBCursor,删除了我的答案,向上投票:)
> a2 = db.c.find( {x : 100} )
> a2.hasNext()
false