-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Campground Schema with Validation, Timestamps, and Improved Error Logging #363
Conversation
@smog-root ,In the new campground form, when the title is less than 3 characters, it throws a 'bad gateway' error. However, in the edit campground form, it correctly shows the error message indicating that the title is too short. Please check and fix this inconsistency. |
When validation errors occur (like the title being too short), users are redirected back to the form with a clear message, preventing any 'bad gateway' errors.
@Vignesh025 Done!! |
const mongoose = require('mongoose'); | ||
const Review = require('./review'); // Model for associated reviews | ||
const Schema = mongoose.Schema; // Extract Schema for easier usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo the deletion
The issue is still there, it's not resolved. |
@Vignesh025 Done!! |
const express = require('express'); | ||
const router = express.Router(); | ||
const Campground = require(''./review''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you delete these lines?
and the issue we have mentioned is still there.
@Vignesh025 I will fix it!! Wait!! |
Closes #361
Kindly add all the labels and assign me! @Vignesh025
Summary of Changes:
1. Validation Constraints:
minlength: 3
fortitle
.min: 0
forprice
.2. Timestamps:
createdAt
andupdatedAt
fields.3. Enhanced Error Logging:
findOneAndDelete
middleware to include the campground ID and number of deleted reviews for better debugging.This updated version includes all features requested, making the schema more robust and informative. Let me know if further adjustments are needed!