Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

smog-root
Copy link
Contributor

@smog-root smog-root commented Nov 3, 2024

Closes #361

Kindly add all the labels and assign me! @Vignesh025

Summary of Changes:

1. Validation Constraints:

  • Added minlength: 3 for title.
  • Added min: 0 for price.

2. Timestamps:

  • Enabled timestamps in the schema options, adding createdAt and updatedAt fields.

3. Enhanced Error Logging:

  • Improved logging in 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!

@Vignesh025
Copy link
Contributor

@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.
@smog-root
Copy link
Contributor Author

@Vignesh025 Done!!

Comment on lines -2 to -4
const mongoose = require('mongoose');
const Review = require('./review'); // Model for associated reviews
const Schema = mongoose.Schema; // Extract Schema for easier usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo the deletion

@Vignesh025
Copy link
Contributor

The issue is still there, it's not resolved.

@smog-root
Copy link
Contributor Author

@Vignesh025 Done!!

Comment on lines 2 to 4
const express = require('express');
const router = express.Router();
const Campground = require(''./review'');
Copy link
Contributor

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.

@smog-root
Copy link
Contributor Author

@Vignesh025 I will fix it!! Wait!!

@smog-root smog-root closed this Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants