MongoDB Show all contents from all collections

前端 未结 8 1784
刺人心
刺人心 2020-12-07 07:45

Is it possible to show all collections and its contents in MongoDB?

Is the only way to show one by one?

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 08:21

    This will do:

    db.getCollectionNames().forEach(c => {
        db[c].find().forEach(d => {
            print(c); 
            printjson(d)
        })
    })
    

提交回复
热议问题