mdazfar2 / Ezyshop

EzyShop is a user-friendly platform that connects you to local stores, offering a seamless shopping experience. Compare prices, access exclusive deals, and enjoy hassle-free deliveries for groceries, essentials, and organic products—all in one app.
https://ezyshopz.vercel.app
Apache License 2.0
148 stars 187 forks source link

[Feat] Setup Blog Schema and Implement Blog Data Fetching from Database #928

Open kavya410004 opened 2 hours ago

kavya410004 commented 2 hours ago

Description

Description:
The blog functionality is not yet implemented in the application. To support blog posts, we first need to create a database schema for blogs and set up fetching data from the database. This will provide the foundation for adding blog-related features in future tasks, such as displaying blog summaries and individual blog content on the frontend.

Proposed Solution:

  1. Define the Blog Schema:

    • Create a new Blog model in the schema.prisma file with fields such as:
      • id: Unique identifier for each blog.
      • title: Title of the blog post.
      • content: Main content of the blog.
      • image: URL for the blog's cover image.
      • authorId: Identifier linking the blog to a User.
      • createdAt: Timestamp of when the blog was created.
      • updatedAt: Timestamp of when the blog was last updated.
    • Establish relationships if needed (e.g., link blogs to User as author).
    • Run prisma db push to sync the new schema with the MongoDB database.
  2. Create Sample Blog Data:

    • Add 2-3 initial blog entries to the database to facilitate testing of the fetching logic.
  3. Set Up Data Fetching Logic:

    • Implement backend API endpoints to retrieve blog data.
    • Create endpoints such as:
      • GET /api/blogs: Fetch a list of blog summaries.
      • GET /api/blogs/:id: Fetch full details of a specific blog by id.
    • Ensure the data retrieval works correctly and returns the necessary fields for displaying on the frontend.

Expected Outcome:

Additional Information:
This foundational setup will allow for a seamless transition to implementing the Blog Grid page and individual Blog Page functionality in a follow-up issue. The next step will focus on dynamically loading the blog content using this database connection.

Screenshots

Current blog page with static details:

image

Checklist

github-actions[bot] commented 2 hours ago

Hello kavya410004! Thanks for opening an issue in Ezyshop! 🚀