Findmany不是MongoDB的功能
我在网站上进行了评论系统。我将所有评论数据存储在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用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.