monkeytype/backend/models/leaderboard.js

33 lines
802 B
JavaScript
Raw Normal View History

2021-05-27 02:55:42 +08:00
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const leaderboardEntrySchema = new Schema({
name: String,
wpm: Number,
raw: Number,
acc: Number,
consistency: Number, //can be null
mode: String, //not sure why mode and mode2 are needed
mode2: Number,
timestamp: Date, //Is this the right type?
hidden: Boolean,
});
const leaderboardSchema = new Schema(
{
resetTime: Date, //or Number, only on daily lb
size: Number,
board: [{ type: leaderboardEntrySchema }], //contents of leaderbaord
mode: String, //only time for now
mode2: Number, //only 15 and 60 for now
type: String, //global or local
},
{
timestamps: true,
}
);
const Leaderboard = mongoose.model("Leaderboard", leaderboardSchema);
module.exports = { Leaderboard };