Initial commit

This commit is contained in:
Lorenzo Sanesi
2026-03-26 22:46:03 +01:00
commit 18e0e04700
80 changed files with 13114 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
const BetParticipantSchema = new Schema({
user: { type: Number, required: true }, // Stores the PostgreSQL User ID
role: { type: String, enum: ['PARTICIPANT', 'OBSERVER'], required: true },
}, { _id: false });
const BetSchema = new mongoose.Schema({
title: { type: String, required: true },
description: { type: String },
stake: { type: String, required: true },
participants: [BetParticipantSchema],
status: { type: String, enum: ['ACTIVE', 'AWAITING_VALIDATION', 'COMPLETED', 'EXPIRED'], required: true },
startDate: { type: Date, default: Date.now },
endDate: { type: Date, default: null },
isPublic: { type: Boolean, default: false },
groupId: { type: String, default: null }, // Stores the PostgreSQL Group ID
winner: { type: Number, default: null }, // Stores the PostgreSQL User ID
});
BetSchema.set('toJSON', {
virtuals: true,
versionKey: false,
transform: function (doc, ret) {
delete ret._id;
}
});
module.exports = mongoose.model('Bet', BetSchema);