Shops in the Marketplace
Sellers on MERN Marketplace can create shops and add products to each shop. To store the shop data and enable shop management, we will implement a Mongoose Schema for shops, backend APIs to access and modify the shop data, and frontend views for the shop owner and buyers browsing through the marketplace.
Shop model
The Shop schema defined in server/models/shop.model.js
will have simple fields to store shop details, along with a logo image, and a reference to the user who owns the shop.
- Shop name and description:Â Name and description fields will be string types, with
name
as a required field:
name: { type: String, trim: true, required: 'Name is required' }, description: { type: String, trim: true },
- Shop logo image:Â The
image
field will store the logo image file to be uploaded by the user, as data in the MongoDB database:
image: { data: Buffer, contentType: String },
- Shop owner:Â The owner field will reference the user who is creating...