55 lines
935 B
JavaScript
55 lines
935 B
JavaScript
import mongoose from 'mongoose';
|
|
|
|
const gameSchema = new mongoose.Schema({
|
|
gameCode: {
|
|
type: String,
|
|
required: true,
|
|
unique: true
|
|
},
|
|
hostId: String,
|
|
hostName: String,
|
|
teams: [{
|
|
id: String,
|
|
name: String,
|
|
score: { type: Number, default: 0 },
|
|
players: [{
|
|
id: String
|
|
}]
|
|
}],
|
|
currentRound: {
|
|
type: Number,
|
|
default: 1
|
|
},
|
|
selectedCategories: {
|
|
type: mongoose.Schema.Types.Mixed,
|
|
default: []
|
|
},
|
|
usedCategoryIds: {
|
|
type: [String],
|
|
default: []
|
|
},
|
|
usedQuestions: [{
|
|
category: String,
|
|
points: Number
|
|
}],
|
|
status: {
|
|
type: String,
|
|
enum: ['waiting', 'playing', 'finished'],
|
|
default: 'waiting'
|
|
},
|
|
currentQuestion: {
|
|
type: mongoose.Schema.Types.Mixed,
|
|
default: null
|
|
},
|
|
answeringTeam: {
|
|
type: String,
|
|
default: null
|
|
}
|
|
}, {
|
|
timestamps: true
|
|
});
|
|
|
|
const Game = mongoose.model('Game', gameSchema);
|
|
|
|
export default Game;
|