From 682f59926161615399550027f55dca81c4df1f42 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sat, 25 Oct 2025 14:33:51 -0700 Subject: [PATCH] fixing updateUser script --- util/users/dev/updateUser.js | 31 +++++++++++++++++++++++ util/users/{ => production}/updateUser.js | 0 2 files changed, 31 insertions(+) create mode 100644 util/users/dev/updateUser.js rename util/users/{ => production}/updateUser.js (100%) diff --git a/util/users/dev/updateUser.js b/util/users/dev/updateUser.js new file mode 100644 index 0000000..ef5c99d --- /dev/null +++ b/util/users/dev/updateUser.js @@ -0,0 +1,31 @@ +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.findOne({ + email: 'test@test.com' + }, '-password') + // console.log('user: ', user) + + // Update the users password + user.password = 'test' + + // Change the user to an admin + // user.type = 'admin' + + // Save the changes to the database. + await user.save() + + mongoose.connection.close() +} +getUsers() diff --git a/util/users/updateUser.js b/util/users/production/updateUser.js similarity index 100% rename from util/users/updateUser.js rename to util/users/production/updateUser.js