MongoDB之shell遍历db.getCollectionNames()表集合

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yaomingyang/article/details/82944032
  • 获取数据库中的所有文档集合
var t=db.getCollectionNames()
  • 通过for循环的方式遍历文档集合
for(var i=0;i<t.length;i++){
    print(t[i])
}
  • 通过forEach方式遍历文档集合
t.forEach(function(item){
        print(item)
   }
)

猜你喜欢

转载自blog.csdn.net/yaomingyang/article/details/82944032
今日推荐