Implemented the User model using Mongoose for MongoDB.
Defined the schema with the following fields:
email: Stores the user's email address. It is required, unique, and validated using a regular expression to ensure proper format.
password: Stores the user's hashed password. It is required and securely hashed using bcrypt before saving.
preferences: An array to store user preferences (e.g., categories of interest). Defaults to an empty array.
searches: An array to store recent searches made by the user. Defaults to an empty array.
recommendations: An array of references to the Recommendation model, linking user recommendations.
viewedAttractions: An array of references to the Attraction model, tracking attractions the user has viewed.
dateJoined: Records the date when the user registered, defaulting to the current date.
Added a pre-save hook to hash passwords before storing them in the database for enhanced security.
Included a method to compare user-entered passwords with the stored hashed password.
Enabled timestamps to automatically record createdAt and updatedAt for each user document.
Description:
Implemented the User model using Mongoose for MongoDB.
Defined the schema with the following fields:
email: Stores the user's email address. It is required, unique, and validated using a regular expression to ensure proper format.
password: Stores the user's hashed password. It is required and securely hashed using bcrypt before saving.
preferences: An array to store user preferences (e.g., categories of interest). Defaults to an empty array.
searches: An array to store recent searches made by the user. Defaults to an empty array.
recommendations: An array of references to the Recommendation model, linking user recommendations.
viewedAttractions: An array of references to the Attraction model, tracking attractions the user has viewed.
dateJoined: Records the date when the user registered, defaulting to the current date.
Added a pre-save hook to hash passwords before storing them in the database for enhanced security. Included a method to compare user-entered passwords with the stored hashed password. Enabled timestamps to automatically record createdAt and updatedAt for each user document.
;