Product Collection: json Copy code { "_id": ObjectId("..."), "name": "Product Name", "description": "Product Description", "price": 19.99, "category": "Electronics", "inventory": 100, "reviews": [ { "userId": ObjectId("..."), "username": "username", "rating": 4, "comment": "Great product!", "date": ISODate("2023-01-01T12:00:00Z") } ], "createdAt": ISODate("2023-01-01T08:00:00Z"), "updatedAt": ISODate("2023-01-01T08:30:00Z") } _id: Unique identifier for the product. name: Name of the product. description: Description of the product. price: Price of the product. category: Category to which the product belongs. inventory: Quantity of the product available in stock. reviews: Array of review documents, each containing information about the user, rating, comment, and date. createdAt: Timestamp indicating when the product was created. updatedAt: Timestamp indicating when the product was last updated. 2. User Collection: json Copy code { "_id": ObjectId("..."), "username": "username", "email": "user@example.com", "password": "hashed_password", "role": "customer", "createdAt": ISODate("2023-01-01T10:00:00Z"), "updatedAt": ISODate("2023-01-01T10:30:00Z") } _id: Unique identifier for the user. username: Username of the user. email: Email address of the user. password: Hashed password of the user. role: Role of the user (e.g., customer, admin). createdAt: Timestamp indicating when the user was created. updatedAt: Timestamp indicating when the user was last updated. 3. Reviews Collection (if separate from Products): json Copy code { "_id": ObjectId("..."), "productId": ObjectId("..."), "userId": ObjectId("..."), "rating": 4, "comment": "Great product!", "date": ISODate("2023-01-01T12:00:00Z") } _id: Unique identifier for the review. productId: Reference to the product being reviewed. userId: Reference to the user who wrote the review. rating: Rating given by the user. comment: Comment provided by the user. date: Timestamp indicating when the review was posted. 4. Order Collection: json Copy code { "_id": ObjectId("..."), "userId": ObjectId("..."), "products": [ { "productId": ObjectId("..."), "quantity": 2, "price": 19.99 } ], "totalPrice": 39.98, "status": "pending", "createdAt": ISODate("2023-01-02T14:00:00Z"), "updatedAt": ISODate("2023-01-02T14:30:00Z") } _id: Unique identifier for the order. userId: Reference to the user who placed the order. products: Array of product items in the order, each containing productId, quantity, and price. totalPrice: Total price of the order. status: Status of the order (e.g., pending, shipped). createdAt: Timestamp indicating when the order was created. updatedAt: Timestamp indicating when the order was last updated.
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter