2021-05-15 01:56:08 +08:00
|
|
|
const mongoose = require("mongoose");
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
2021-05-26 08:47:43 +08:00
|
|
|
const { configSchema } = require("./subschemas/config");
|
|
|
|
const { resultSchema } = require("./subschemas/result");
|
|
|
|
const { tagSchema } = require("./subschemas/tag");
|
|
|
|
const { presetSchema } = require("./subschemas/preset");
|
2021-05-22 11:41:43 +08:00
|
|
|
|
2021-05-15 01:56:08 +08:00
|
|
|
const userSchema = new Schema(
|
|
|
|
{
|
2021-06-06 19:52:28 +08:00
|
|
|
_id: { type: String },
|
2021-05-22 11:41:43 +08:00
|
|
|
results: [{ type: resultSchema, default: {} }],
|
2021-05-15 04:16:06 +08:00
|
|
|
personalBests: {
|
|
|
|
custom: { type: Schema.Types.Mixed, default: {} },
|
|
|
|
time: { type: Schema.Types.Mixed, default: {} },
|
|
|
|
words: { type: Schema.Types.Mixed, default: {} },
|
|
|
|
zen: { type: Schema.Types.Mixed, default: {} },
|
|
|
|
},
|
|
|
|
name: { type: String, required: true },
|
2021-06-01 11:47:58 +08:00
|
|
|
uid: { type: String, required: true },
|
2021-06-04 02:05:35 +08:00
|
|
|
discordId: { type: String },
|
2021-05-26 03:25:02 +08:00
|
|
|
presets: [{ type: presetSchema, default: {} }],
|
2021-05-22 11:41:43 +08:00
|
|
|
tags: [{ type: tagSchema, default: {} }],
|
2021-05-15 04:16:06 +08:00
|
|
|
favouriteThemes: [],
|
2021-05-20 04:08:39 +08:00
|
|
|
refactored: { type: Boolean, default: true },
|
2021-05-15 04:16:06 +08:00
|
|
|
banned: { type: Boolean, default: false },
|
2021-05-27 23:08:40 +08:00
|
|
|
verified: { type: Boolean, default: false }, //Verified is actually whether or not discord account is connected
|
2021-05-15 04:16:06 +08:00
|
|
|
emailVerified: { type: Boolean, default: false },
|
|
|
|
lbMemory: {
|
|
|
|
time15: {
|
2021-06-03 10:03:37 +08:00
|
|
|
global: { type: Number, default: -1 },
|
2021-06-02 08:16:23 +08:00
|
|
|
daily: { type: Number, default: -1 },
|
2021-05-15 04:16:06 +08:00
|
|
|
},
|
|
|
|
time60: {
|
2021-06-02 08:16:23 +08:00
|
|
|
global: { type: Number, default: -1 },
|
|
|
|
daily: { type: Number, default: -1 },
|
2021-05-15 04:16:06 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
globalStats: {
|
|
|
|
time: { type: Number, default: 0 },
|
|
|
|
started: { type: Number, default: 0 }, //number of started tests
|
|
|
|
completed: { type: Number, default: 0 },
|
|
|
|
},
|
2021-06-01 11:47:58 +08:00
|
|
|
email: { type: String },
|
2021-05-26 08:47:43 +08:00
|
|
|
config: { type: configSchema, default: {} },
|
2021-05-27 03:36:02 +08:00
|
|
|
bananas: {
|
|
|
|
t60bananas: { type: Number, default: 0 },
|
|
|
|
},
|
2021-06-04 02:05:35 +08:00
|
|
|
dailyLbWins: {
|
|
|
|
time15: { type: Number },
|
|
|
|
time60: { type: Number },
|
|
|
|
},
|
2021-05-15 01:56:08 +08:00
|
|
|
},
|
2021-05-15 04:16:06 +08:00
|
|
|
{
|
|
|
|
timestamps: true,
|
|
|
|
minimize: false, //allows empty objects to be saved to mongodb
|
|
|
|
}
|
2021-05-15 01:56:08 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
const User = mongoose.model("User", userSchema);
|
|
|
|
|
|
|
|
module.exports = { User };
|