diff --git a/util/users/updateUser.js b/util/users/updateUser.js new file mode 100644 index 0000000..3ad2108 --- /dev/null +++ b/util/users/updateUser.js @@ -0,0 +1,30 @@ +import mongoose from 'mongoose' +import config from '../../config/index.js' +import User from '../../src/adapters/localdb/models/users.js' + +async function getUsers () { + // Connect to the Mongo Database. + mongoose.Promise = global.Promise + mongoose.set('useCreateIndex', true) // Stop deprecation warning. + await mongoose.connect( + config.database, + { useNewUrlParser: true, useUnifiedTopology: true } + ) + + // Find the user by email. + const user = await User.find({ + 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()