gpt4 book ai didi

javascript - 如何将所有 Meteor Mongo 集合名称检索为 Javascript 数组?

转载 作者:可可西里 更新时间:2023-11-01 09:24:22 25 4
gpt4 key购买 nike

我尝试使用:

MongoInternals.defaultRemoteCollectionDriver().mongo.db.listCollections()

为了获取 meteor 数据库中的所有集合名称,但它返回了一个很长的 JSON,我在其中找不到纯集合名称。 (见附图)

enter image description here

如何获取以下格式的 meteor 集合名称:

["test1", "test2", "users"...]

最佳答案

好的,这是工作代码,谢谢@PaulS。

db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
collections = db.listCollections();

collections.each(function(n, collection){
if(collection){
console.log( collection.name );
}
});

关于javascript - 如何将所有 Meteor Mongo 集合名称检索为 Javascript 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34556201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com