简体   繁体   中英

Read document from list collection mongodb

db(database).listCollection().toArray(function (error, isListCollection){if(error){response.json(error.message)}else if(isListCollection){for(var i = 0; i < isListCollection.length; i++){const listColl = isListcoll.name; db(database).collection(listColl, (error, data) => { if(errr){responden.json(error.message)}else if(data){respons.json(data)});}

How to loop and push the respon data to Json file. Thanks

Are you trying to take backup? If yes there is a command mongoexport you can use to get response directly in json format. It is provided by mongo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM