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

Create Responses Table for Contact Us Messages #3

Open
mahendra785 opened this issue Aug 20, 2024 · 1 comment
Open

Create Responses Table for Contact Us Messages #3

mahendra785 opened this issue Aug 20, 2024 · 1 comment

Comments

@mahendra785
Copy link
Collaborator

Set up a new table in the database called responses. When a user submits a message through the Contact Us form, save their details (e.g., name, email, message) into this table. This will help keep a record of all the messages received.

@D-Vspec
Copy link
Collaborator

D-Vspec commented Aug 20, 2024

Pseudocode: Create Responses Collection for Contact Us Messages

Objective:

Set up a new collection in the NoSQL database called responses. When a user submits a message through the Contact Us form, their details (e.g., name, email, message) should be saved in this collection. This will help keep a record of all the messages received.

Steps:

1. Define the responses Collection Structure

  • Collection Name: responses
  • Document Structure:
    • _id: Automatically generated unique identifier (e.g., MongoDB ObjectId)
    • name: The name of the user (e.g., String)
    • email: The email of the user (e.g., String)
    • message: The message submitted by the user (e.g., String)
    • createdAt: Timestamp for when the message was submitted (e.g., Date, default: current date/time)

2. Create the Schema in Mongoose

  • Mongoose Schema Example:

    const mongoose = require('mongoose');
    
    const responseSchema = new mongoose.Schema({
        name: {
            type: String,
            required: true
        },
        email: {
            type: String,
            required: true
        },
        message: {
            type: String,
            required: true
        },
        createdAt: {
            type: Date,
            default: Date.now
        }
    });
    
    const Response = mongoose.model('Response', responseSchema);

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

No branches or pull requests

2 participants