const mongoose = require('mongoose');
const tourSchema = new mongoose.Schema({
name: { type: String, trim: true, required: true, unique: true },
rating: { type: Number, default: 4.5 },
price: { type: Number, required: [true, 'A tour must have price'] },
duration: { type: Number, required: [true, 'A tour must have a duration'] },
maxGroupSize: {
type: Number,
required: [true, 'A tour must have a group size'],
},
difficulty: { type: String, required: [true, 'A tour must have difficulty'] },
ratingAverage: { type: Number, default: 4.5 },
ratingQuantity: { type: Number, default: 0 },
priceDiscount: Number,
summary: {
type: String,
trim: true,
required: [true, 'A tour must have a description'],
},
description: { type: String, trim: true },
imageCover: {
type: String,
required: [true, 'A tour must have a cover image'],
},
image: [String],
createdAt: { type: Date, dafault: Date.now(), select: false },
startDates: [Date],
});
const Tour = mongoose.model('Tour', tourSchema);
module.exports = Tour;
let movieSchema = mongoose.Schema({
Title: {type: String, required: true},
Description: {type: String, required: true},
Genre: {
Name: String,
Description: String
},
Director: {
Name: String,
Bio: String
},
Actors: [String],
ImagePath: String,
Featured: Boolean
});
let userSchema = mongoose.Schema({
Username: {type: String, required: true},
Password: {type: String, required: true},
Email: {type: String, required: true},
Birthday: Date,
FavoriteMovies: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Movie' }]
});
let Movie = mongoose.model('Movie', movieSchema);
let User = mongoose.model('User', userSchema);
module.exports.Movie = Movie;
module.exports.User = User;