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:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user