Vibed it... :(

This commit is contained in:
2025-08-09 14:34:48 +01:00
commit 5cf478feab
41 changed files with 23512 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
const mongoose = require('mongoose');
const userSelectionSchema = new mongoose.Schema({
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
selectedRecipes: [{
recipeId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Recipe',
required: true
},
quantity: {
type: Number,
default: 1,
min: 1
},
addedAt: {
type: Date,
default: Date.now
}
}],
aggregatedIngredients: [{
name: String,
totalAmount: Number,
unit: String,
recipes: [{
recipeId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Recipe'
},
recipeTitle: String,
amount: Number,
quantity: Number // recipe quantity multiplier
}]
}],
createdAt: {
type: Date,
default: Date.now
},
updatedAt: {
type: Date,
default: Date.now
}
});
// Update the updatedAt field before saving
userSelectionSchema.pre('save', function(next) {
this.updatedAt = Date.now();
next();
});
module.exports = mongoose.model('UserSelection', userSelectionSchema);