Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database schemas added for user data, quests and settings #74

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.env.development.local
.env.test.local
.env.production.local
yarn.lock

# Logs
npm-debug.log*
Expand Down
35 changes: 35 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions backend/models/quests.js
Original file line number Diff line number Diff line change
@@ -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;
21 changes: 21 additions & 0 deletions backend/models/settings.js
Original file line number Diff line number Diff line change
@@ -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;
29 changes: 23 additions & 6 deletions backend/models/user.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
const mongoose = require("mongoose")
const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const userSchema = new mongoose.Schema({
username: String,
password: String
})
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: {
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: { type: Schema.Types.ObjectId, ref: "Settings" },
});

module.exports = mongoose.model("User", userSchema)
module.exports = mongoose.model("User", userSchema);
Loading