Files
oscars-pool/models/MovieRating.js
Mathieu Moran fe21a12c82 Add user movie ratings and refresh movie cards
Store per-user 5-star ratings with averages and surface them in the player. Refresh movie list layout to show ratings and details in a cleaner card layout.
2026-01-25 16:16:07 -05:00

12 lines
502 B
JavaScript

const mongoose = require("mongoose");
const movieRatingSchema = new mongoose.Schema({
movieId: { type: mongoose.Schema.Types.ObjectId, ref: "Movie", required: true, index: true },
userId: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, index: true },
rating: { type: Number, required: true, min: 1, max: 5 },
}, { timestamps: true });
movieRatingSchema.index({ movieId: 1, userId: 1 }, { unique: true });
module.exports = mongoose.model("MovieRating", movieRatingSchema);