2025-10-25 14:23:28 -07:00
|
|
|
import mongoose from 'mongoose'
|
2025-10-25 14:35:22 -07:00
|
|
|
// import config from '../../config/index.js'
|
2025-10-25 14:23:28 -07:00
|
|
|
import User from '../../src/adapters/localdb/models/users.js'
|
|
|
|
|
|
2025-10-25 14:35:22 -07:00
|
|
|
const mongooseConnectStr = 'mongodb://172.17.0.1:5666/bch-swap-service-prod'
|
|
|
|
|
|
2025-10-25 14:23:28 -07:00
|
|
|
async function getUsers () {
|
|
|
|
|
// Connect to the Mongo Database.
|
|
|
|
|
mongoose.Promise = global.Promise
|
|
|
|
|
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
|
|
|
|
|
await mongoose.connect(
|
2025-10-25 14:35:22 -07:00
|
|
|
mongooseConnectStr,
|
2025-10-25 14:23:28 -07:00
|
|
|
{ useNewUrlParser: true, useUnifiedTopology: true }
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Find the user by email.
|
2025-10-25 14:31:33 -07:00
|
|
|
const user = await User.findOne({
|
2025-10-25 14:23:28 -07:00
|
|
|
email: 'test@test.com'
|
|
|
|
|
}, '-password')
|
|
|
|
|
|
|
|
|
|
// Update the users password
|
|
|
|
|
// user.password = 'newpassword'
|
|
|
|
|
|
|
|
|
|
// Change the user to an admin
|
|
|
|
|
// user.type = 'admin'
|
|
|
|
|
|
|
|
|
|
// Save the changes to the database.
|
|
|
|
|
await user.save()
|
|
|
|
|
|
|
|
|
|
mongoose.connection.close()
|
|
|
|
|
}
|
|
|
|
|
getUsers()
|