Forked from slp-dex

This commit is contained in:
Chris Troutner
2022-02-23 05:51:12 -08:00
commit 7cd858e4e2
167 changed files with 59371 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
/*
Utility app to wipe the test database.
*/
'use strict'
const mongoose = require('mongoose')
// Force test environment
process.env.KOA_ENV = 'test'
const config = require('../config')
async function cleanDb () {
// Connect to the Mongo Database.
mongoose.Promise = global.Promise
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
await mongoose.connect(config.database, { useNewUrlParser: true })
console.log(`mongoose.connection.collections: ${JSON.stringify(mongoose.connection.collections, null, 2)}`)
for (const collection in mongoose.connection.collections) {
const collections = mongoose.connection.collections
if (collections.collection) {
// const thisCollection = mongoose.connection.collections[collection]
// console.log(`thisCollection: ${JSON.stringify(thisCollection, null, 2)}`)
await collection.deleteMany()
}
}
mongoose.connection.close()
}
cleanDb()