From 6a81b0c781d831a0cc9af9696984858d2e811cbe Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 17 Nov 2022 11:35:46 +0000 Subject: [PATCH] Use default in the model instead of creating it manually --- src/models/UserModel.js | 20 ++++++++++++++++---- src/utils/helpers/userHelpers.js | 7 ------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/models/UserModel.js b/src/models/UserModel.js index 4c70e5a..963f3af 100644 --- a/src/models/UserModel.js +++ b/src/models/UserModel.js @@ -13,10 +13,22 @@ const schema = new Schema({ // User Settings discordEmbed: { - embed: Boolean, - title: String, - description: String, - color: String, + embed: { + type: Boolean, + default: true, + }, + title: { + type: String, + default: "{id}.{ext}", + }, + description: { + type: String, + default: null, + }, + color: { + type: String, + default: "0063EB", + }, }, }); diff --git a/src/utils/helpers/userHelpers.js b/src/utils/helpers/userHelpers.js index 43ed58b..5292647 100644 --- a/src/utils/helpers/userHelpers.js +++ b/src/utils/helpers/userHelpers.js @@ -46,13 +46,6 @@ export async function createUser(username, password) { password: hashPassword(salt, password), salt: salt, uploadKey: randomString(16), - - discordEmbed: { - embed: true, - title: "{id}.{ext}", - description: null, - color: "0063EB", - }, }); user.save(); } catch (e) {