From 19090985f5c518997b8fe1d22b43321191a180b4 Mon Sep 17 00:00:00 2001 From: dusek2 Date: Thu, 4 Apr 2024 13:41:08 -0700 Subject: [PATCH 1/5] adding user model --- app/.gitignore | 1 + backend/.gitignore | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 backend/.gitignore diff --git a/app/.gitignore b/app/.gitignore index 9d2f2a8..bd52383 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -11,6 +11,7 @@ .env.development.local .env.test.local .env.production.local +yarn.lock # Logs npm-debug.log* diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..9d2f2a8 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,35 @@ + +# Dependencies +/node_modules + +# Production +/build + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.log + +# Editor directories and files +.idea +.vscode/ +*.swp +*.swo +*.swn + +# OS-specific +Thumbs.db + From e78cfcbf8cf499eabab7b0b826bc9a7ceb3b0e0c Mon Sep 17 00:00:00 2001 From: dusek2 Date: Thu, 4 Apr 2024 13:59:37 -0700 Subject: [PATCH 2/5] adding schemas for quests and settings --- backend/models/quests.js | 20 ++++++++++++++++++++ backend/models/settings.js | 21 +++++++++++++++++++++ backend/models/user.js | 25 +++++++++++++++++++------ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 backend/models/quests.js create mode 100644 backend/models/settings.js diff --git a/backend/models/quests.js b/backend/models/quests.js new file mode 100644 index 0000000..0a28eb4 --- /dev/null +++ b/backend/models/quests.js @@ -0,0 +1,20 @@ +const mongoose = require("mongoose"); +const { Schema } = mongoose; + +const questSchema = new Schema({ + // quest info + title: String, + description: String, + // changes that will be made to the user's stats + statImprovements: { + MeStat: Number, + WorkStat: Number, + LoveStat: Number, + }, + // requirements to complete the quest + requirements: String, +}); + +const Quest = mongoose.model("Quest", questSchema); + +module.exports = Quest; diff --git a/backend/models/settings.js b/backend/models/settings.js new file mode 100644 index 0000000..dfa9a8e --- /dev/null +++ b/backend/models/settings.js @@ -0,0 +1,21 @@ +const mongoose = require("mongoose"); +const { Schema } = mongoose; + +const settingsSchema = new Schema({ + // relates to user + userId: { + type: Schema.Types.ObjectId, + ref: "User", + required: true, + unique: true, + }, + // relates to adjustments of user interface + uiPreferences: { + fontSize: { type: Number, default: 14 }, + theme: { type: String, default: "light" }, + }, +}); + +const Settings = mongoose.model("Settings", settingsSchema); + +module.exports = Settings; diff --git a/backend/models/user.js b/backend/models/user.js index 59abc88..ec9389e 100644 --- a/backend/models/user.js +++ b/backend/models/user.js @@ -1,8 +1,21 @@ -const mongoose = require("mongoose") +const mongoose = require("mongoose"); -const userSchema = new mongoose.Schema({ - username: String, - password: String -}) +const userSchema = new Schema({ + // user info + username: String, + password: String, + email: String, + completedQuiz: Boolean, + // life stats + stats: { + MeStat: Number, + WorkStat: Number, + LoveStat: Number, + }, + // user's quests + quests: [{ type: Schema.Types.ObjectId, ref: "Quest" }], + // user's settings + settings: Object, +}); -module.exports = mongoose.model("User", userSchema) \ No newline at end of file +module.exports = mongoose.model("User", userSchema); From fb70b593d13e5d3d232e234d8e6082be0a5b0ede Mon Sep 17 00:00:00 2001 From: dusek2 Date: Thu, 4 Apr 2024 14:17:20 -0700 Subject: [PATCH 3/5] Improving user model --- backend/models/user.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/backend/models/user.js b/backend/models/user.js index ec9389e..bf094f7 100644 --- a/backend/models/user.js +++ b/backend/models/user.js @@ -1,21 +1,22 @@ const mongoose = require("mongoose"); +const Schema = mongoose.Schema; const userSchema = new Schema({ // user info - username: String, - password: String, - email: String, - completedQuiz: Boolean, + username: { type: String, required: true, unique: true }, + password: { type: String, required: true }, + email: { type: String, required: true, unique: true }, + completedQuiz: { type: Boolean, default: false }, // life stats stats: { - MeStat: Number, - WorkStat: Number, - LoveStat: Number, + MeStat: { type: Number, default: 0 }, + WorkStat: { type: Number, default: 0 }, + LoveStat: { type: Number, default: 0 }, }, // user's quests quests: [{ type: Schema.Types.ObjectId, ref: "Quest" }], // user's settings - settings: Object, + settings: { type: Schema.Types.ObjectId, ref: "Settings" }, }); module.exports = mongoose.model("User", userSchema); From f96181dff7ec1cdf0b4eb76a7bd85b472c18fa36 Mon Sep 17 00:00:00 2001 From: Kamil Dusejovsky <74691395+dusek2@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:13:13 -0700 Subject: [PATCH 4/5] Update user.js --- backend/models/user.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/models/user.js b/backend/models/user.js index bf094f7..2221590 100644 --- a/backend/models/user.js +++ b/backend/models/user.js @@ -3,9 +3,8 @@ const Schema = mongoose.Schema; const userSchema = new Schema({ // user info - username: { type: String, required: true, unique: true }, - password: { type: String, required: true }, email: { type: String, required: true, unique: true }, + password: { type: String, required: true }, completedQuiz: { type: Boolean, default: false }, // life stats stats: { From ed62144c30c54d33cd9ac8186b23aa6f14d967c0 Mon Sep 17 00:00:00 2001 From: Kamil Dusejovsky <74691395+dusek2@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:46:53 -0700 Subject: [PATCH 5/5] Update user.js --- backend/models/user.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/models/user.js b/backend/models/user.js index 2221590..065f571 100644 --- a/backend/models/user.js +++ b/backend/models/user.js @@ -5,6 +5,10 @@ const userSchema = new Schema({ // user info email: { type: String, required: true, unique: true }, password: { type: String, required: true }, + name: { + first: String, + last: String, + }, completedQuiz: { type: Boolean, default: false }, // life stats stats: {