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.
		
			
				
	
	
		
			20 lines
		
	
	
		
			392 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			392 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const mongoose = require("mongoose");
 | |
| const Schema = mongoose.Schema;
 | |
| 
 | |
| const PreLotteryWine = new Schema({
 | |
|   name: String,
 | |
|   vivinoLink: String,
 | |
|   rating: Number,
 | |
|   id: String,
 | |
|   year: Number,
 | |
|   image: String,
 | |
|   price: String,
 | |
|   country: String,
 | |
|   winner: {
 | |
|     type: Schema.Types.ObjectId,
 | |
|     ref: "VirtualWinner"
 | |
|   }
 | |
| });
 | |
| 
 | |
| module.exports = mongoose.model("PreLotteryWine", PreLotteryWine);
 |