Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在猫鼬中使用解释()。db.collection.find().explain() 在猫鼬中的等效语句是什么(这在 mongodb 终端中有效)?我在文档中找不到答案
不是直接的。但是,您可以做的是启用 Mongoose 的调试日志记录,以便您可以看到它正在使用的实际查询,然后将其复制到 MongoDB shell 中并explain()在其上运行。
explain()
要启用 Mongoose 的调试日志记录到控制台,请将以下内容添加到您的代码中:
mongoose.set('debug', true);