Listing all collections in a mongo database within a nodejs script

前端 未结 4 1030
春和景丽
春和景丽 2020-12-09 15:22

I have found a few answers for listing collections in the shell but all the answers I have found for listing collections in a nodejs script seem to have been deprecated, ans

4条回答
  •  春和景丽
    2020-12-09 16:02

    const collections = Object.keys(mongoose.connection.collections); 
    

    this gives you a JSON document of your collections.

提交回复
热议问题