Files
homepage/src/models/UserFavorites.ts
Alexander Bocken cd54ad0498 Implement user favorites feature for recipes
- Add UserFavorites MongoDB model with ObjectId references
- Create authenticated API endpoints for favorites management
- Add Heart icon and FavoriteButton components with toggle functionality
- Display favorite button below recipe tags for logged-in users
- Add Favoriten navigation link (visible only when authenticated)
- Create favorites page with grid layout and search functionality
- Store favorites by MongoDB ObjectId for data integrity

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 20:18:57 +02:00

11 lines
364 B
TypeScript

import mongoose from 'mongoose';
const UserFavoritesSchema = new mongoose.Schema(
{
username: { type: String, required: true, unique: true },
favorites: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Recipe' }] // Recipe MongoDB ObjectIds
},
{ timestamps: true }
);
export const UserFavorites = mongoose.model("UserFavorites", UserFavoritesSchema);