Findmany不是MongoDB的功能

发布于 2025-02-13 06:06:41 字数 183 浏览 1 评论 0原文

我在网站上进行了评论系统。我将所有评论数据存储在MongoDB中,现在我非常需要访问该数据以将注释打印给用户。但是,我看到收集对象没有“发现”功能。我只需要在数组中获取集合中的所有代码。 FindOne找到一个文档,然后Findmany应该在那里吧?集合对象中是否还有其他此类功能可以为我提供蒙古数据库集合中的所有数据,

任何帮助都很棒!

I was making a commenting system on my website. I stored all the comment data in MongoDB and now I abviously need to access that data to print out the comments to a user. But, I see that there is no 'findMany' function for the collection object. I just need to get all the code in the collection in an array. findOne finds one document, then findMany should be there right? Is there any other such function in the collection object which can give me all the data in a collection of a database in MongoDB

Any help would be great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2025-02-20 06:06:41

您必须使用find()。toarray()方法,而不是findmany({})将所有数据在集合中获取并将数据保存在数组中。这将为您提供一个包含集合中所有数据的数组。

You must use the find().toArray() method instead of findMany({ }) to get all the data there in the collection and to keep that data in an array. This will give you an array with all the data in the collection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文