mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
34 lines
875 B
JavaScript
34 lines
875 B
JavaScript
import mongoose from 'mongoose'
|
|
|
|
// Force test environment
|
|
// make sure environment variable is set before this file gets called.
|
|
// see test script in package.json.
|
|
// process.env.KOA_ENV = 'test'
|
|
import config from '../../config'
|
|
|
|
import User from '../../src/models/users'
|
|
|
|
async function deleteUsers () {
|
|
// Connect to the Mongo Database.
|
|
mongoose.Promise = global.Promise
|
|
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
|
|
await mongoose.connect(config.database, {
|
|
useUnifiedTopology: true,
|
|
useNewUrlParser: true
|
|
})
|
|
|
|
// Get all the users in the DB.
|
|
const users = await User.find({}, '-password')
|
|
// console.log(`users: ${JSON.stringify(users, null, 2)}`)
|
|
|
|
// Delete each user.
|
|
for (let i = 0; i < users.length; i++) {
|
|
const thisUser = users[i]
|
|
await thisUser.remove()
|
|
}
|
|
|
|
mongoose.connection.close()
|
|
}
|
|
|
|
deleteUsers()
|