-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from dusek2/database
Database schemas added for user data, quests and settings
- Loading branch information
Showing
5 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
yarn.lock | ||
|
||
# Logs | ||
npm-debug.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |