When selecting prize, add winner to wine.

Changed the way we register a prize for winner.
Now we have a new prize_selected boolean field on a winner. This is
used to filter on when finding what winners have not selected a prize
yet. This also replaces the previous method of removing virtualWinners
after they selected a prize.

PrelotteryWine also get's a winner reference. This is used to filter on
when finding what prizes are left, and also makes it easier to
archive/register a lottery when the wine has a winner attached.
This commit is contained in:
2021-02-18 20:50:30 +01:00
parent 4bd3b688e9
commit a28a8ccacb
4 changed files with 30 additions and 9 deletions

View File

@@ -9,7 +9,11 @@ const PreLotteryWine = new Schema({
year: Number,
image: String,
price: String,
country: String
country: String,
winner: {
type: Schema.Types.ObjectId,
ref: "VirtualWinner"
}
});
module.exports = mongoose.model("PreLotteryWine", PreLotteryWine);

View File

@@ -10,6 +10,10 @@ const VirtualWinner = new Schema({
red: Number,
yellow: Number,
id: String,
prize_selected: {
type: Boolean,
default: false
},
timestamp_drawn: Number,
timestamp_sent: Number,
timestamp_limit: Number