{"size": 636, "ext": "js", "max_stars_repo_path": "src/scripts/deleteCollections.js", "max_stars_repo_name": "projecttacoma/deqm-test-server", "max_stars_repo_stars_event_min_datetime": "2022-02-03T19:22:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T19:22:02.000Z", "max_issues_repo_path": "src/scripts/deleteCollections.js", "max_issues_repo_name": "projecttacoma/deqm-test-server", "max_issues_repo_issues_event_min_datetime": "2021-08-24T17:42:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T20:07:39.000Z", "max_forks_repo_path": "src/scripts/deleteCollections.js", "max_forks_repo_name": "projecttacoma/deqm-test-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 66, "max_forks_count": null, "avg_line_length": 26.5, "max_line_length": 69, "alphanum_fraction": 0.6996855346}
const mongoUtil = require('../database/connection');

/**
 * Deletes all collections stored in mongo
 */
async function main() {
  // Use connect method to connect to the server
  await mongoUtil.client.connect();
  console.log('Connected successfully to server');

  const collections = await mongoUtil.db.listCollections().toArray();
  const deletions = collections.map(async c => {
    console.log('Deleting collection', c.name);
    return mongoUtil.db.dropCollection(c.name);
  });
  await Promise.all(deletions);
  return 'done.';
}

main()
  .then(console.log)
  .catch(console.error)
  .finally(() => mongoUtil.client.close());
