Polarcraft/webv2/server/utils/models.ts

32 lines
934 B
TypeScript
Raw Normal View History

import { Schema, Types, model } from 'mongoose'
const userSchema = new Schema({
username: { type: String, required: true },
usernameType: { type: String, required: true, default: 'discord' },
discord: {
id: { type: String, required: true, unique: true },
username: { type: String, required: true }
},
minecraft: {
uuid: { type: String, required: false, unique: true },
username: { type: String, required: false }
},
role: {
admin: Boolean,
moderator: Boolean,
teamAdmin: Boolean
},
teamInvites: [
Types.ObjectId
]
2023-06-06 13:48:24 +02:00
})
const whitelistSchema = new Schema({
uuid: { type: String, required: true, unique: true },
connected: { type: Boolean, required: true, default: false },
code: { type: String, required: true, unique: true, length: 6 }
})
export const UserModel = model<IUser>('User', userSchema)
export const WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema)