问题描述
在mongodb中可以用explain来做findOne
吗?
Is it possible to do findOne
with explain in mongodb?
目前我已经尝试过:
db.coll.findOne({query}).explain()
db.collection.findOne({query})._addSpecial( "$explain", 1 )
两者都没有成功.
我知道我可以做限制 1,但是没有它可以做到吗?
I do understand that I can do limit 1, but is it possible to do this without it?
推荐答案
说明完全是游标方法 - https://docs.mongodb.com/manual/reference/method/cursor.explain/#cursor.explain
Explain is completely cursor method - https://docs.mongodb.com/manual/reference/method/cursor.explain/#cursor.explain
根据文档,您不能将游标方法应用于 findOne - https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#the-findone-result-document
According to the documentation, you cannot apply cursor methods to findOne - https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#the-findone-result-document
这篇关于mongodb findOne 与解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!