2023-06-04 22:06:28 +02:00
|
|
|
import { Schema, Types, model } from 'mongoose'
|
|
|
|
|
|
|
|
const userSchema = new Schema({
|
2023-06-06 13:49:27 +02:00
|
|
|
username: { type: String, required: false },
|
2023-06-04 22:06:28 +02:00
|
|
|
usernameType: { type: String, required: true, default: 'discord' },
|
2023-06-06 18:22:36 +02:00
|
|
|
team: { type: Types.ObjectId, ref: 'Team', required: false },
|
2023-06-04 22:06:28 +02:00
|
|
|
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: [
|
2023-06-06 22:28:26 +02:00
|
|
|
{ type: Types.ObjectId, ref: 'Team' }
|
2023-06-04 22:06:28 +02:00
|
|
|
]
|
2023-06-06 13:48:24 +02:00
|
|
|
})
|
2023-06-04 22:06:28 +02:00
|
|
|
|
2023-06-05 16:05:03 +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 }
|
|
|
|
})
|
|
|
|
|
2023-06-06 14:29:05 +02:00
|
|
|
const teamSchema = new Schema({
|
|
|
|
name: { type: String, required: true, minLength: 3, maxLength: 16, unique: true, match: /^[a-zA-Z0-9]+$/ },
|
|
|
|
color: { type: String, required: true, match: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/ },
|
|
|
|
textChannelId: { type: String, required: false },
|
2023-06-06 18:22:36 +02:00
|
|
|
voiceChannelId: { type: String, required: false },
|
|
|
|
members: [
|
|
|
|
{ type: Types.ObjectId, ref: 'User' }
|
|
|
|
]
|
2023-06-06 14:29:05 +02:00
|
|
|
})
|
|
|
|
|
2023-06-04 22:06:28 +02:00
|
|
|
export const UserModel = model<IUser>('User', userSchema)
|
2023-06-05 16:05:03 +02:00
|
|
|
export const WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema)
|
2023-06-06 14:29:05 +02:00
|
|
|
export const TeamModel = model<ITeam>('Team', teamSchema)
|