Skip to content

Implement Comprehensive Product Review Database Schema - #12

Open
HermanL0201 wants to merge 8 commits into
199358a8-4bbc-457d-bb74-b89ae5096bb7from
create-product-reviews-schema-1749179765
Open

Implement Comprehensive Product Review Database Schema#12
HermanL0201 wants to merge 8 commits into
199358a8-4bbc-457d-bb74-b89ae5096bb7from
create-product-reviews-schema-1749179765

Conversation

@HermanL0201

@HermanL0201 HermanL0201 commented Jun 6, 2025

Copy link
Copy Markdown
Owner

Implement Comprehensive Product Review Database Schema

Description

Task

Define a reviews schema with fields for user ID, product ID, rating, review text, and timestamp

Acceptance Criteria

  • Schema must include user ID
  • Schema must include product ID
  • Rating field must be required
  • Support optional review text
  • Implement automatic timestamp tracking

Summary of Work

This pull request adds a robust and feature-rich database schema for product reviews in the Sephora API, providing a flexible and comprehensive solution for managing user product reviews.

Key Implementation Details

  • Created a TypeScript-based Mongoose schema for product reviews
  • Implemented strong type checking with IReview interface
  • Added comprehensive validation for review fields
  • Included timestamp tracking for reviews
  • Prevented duplicate reviews per user-product combination

Schema Features

  • User ID and Product ID references with validation
  • Rating field with min/max constraints (1-5)
  • Optional review text with length validation
  • Automatic timestamp tracking (createdAt, updatedAt)
  • Compound unique index to prevent duplicate reviews

Validation Mechanisms

  • Required fields for user and product IDs
  • Rating range validation (1-5)
  • Review text length limit (1000 characters)
  • Empty review text prevention when rating is provided
  • Automatic timestamp generation

Testing Approach

  • Validated schema constraints programmatically
  • Ensured proper type definitions
  • Verified index and validation logic

Acceptance Criteria Met

✓ Defined schema with user ID, product ID
✓ Implemented rating field
✓ Added review text support
✓ Created timestamp tracking
✓ Implemented robust validation

Changes Made

  • Created comprehensive review schema in src/models/review.model.ts
  • Added TypeScript interface IReview for type safety
  • Implemented validation for all review fields
  • Added compound unique index to prevent duplicate reviews
  • Created custom validation for review text

Tests

  • Verify review schema allows valid review creation
  • Confirm rating is between 1-5
  • Ensure user and product IDs are required
  • Test review text length validation
  • Validate timestamp automatic generation

Signatures

Staking Key

DZwmqbbKALnQYMhTLYdYeBBKVNptDMSAKQjaASJ9btgo: 2jhX7VDnM2UFsSUphopvb2szSjkbD3eLNRYwKKAUn7DGxBHim8TTkm7TcZCgCPGF1v8sdx8wuwykJ2RF8HQPMMEPm8UmzTZoDnTEQ3brzL5sBUxxVNzAqVe228X1zuA1hTKRWYEHS72evUq5VZvoZigqSEUMm8NmioxDhMxiRHfes8rA3tGVUfFxVYL1feMC6fPH7vNsZzuPC8RWY194mE9NMERE2XeYxBiv5WrFD35m6mKzghUoKuC1cnn65SJBNhYBDgwsQAwx17ua6iqaaUz5LowMHuHxhkA88EH2of2k1wxggsLN6sFqZd1mLjUDixHAaPs3ojy7bXoGzD6Tevk4yYBekrDq9ujfcVgvZLJC8cGr9Uw6LaU67YYmp51m2tD8Z7PFcfrBBRo6CpA85hjVwyCGLC7Sapd2

Public Key

4E3nQUGBiknkTFLJE6Htj3KKNnHzpxhNv2Jw5cvW4s7J: B4kVmawuHWxuLffbqz8FYki1wdBK6fwtr72pPXtoy9D3NoQg89mASNFSSHUggejfnz8ynaEi2nfmEDVVx5aiUkSXWNmMENGGxZcyU9qPp7g53sEEwXjv99k7uqwcmxUgbNEmT5igQPuDyLdVcvFLK3EE83qarqJZ2kLCQMJBvfCBjBJsQQZ4envgb4qPK4Ugfmev8n5Qmjm2xReqmzHxTyVWp4sFa8wUfuPGqpjkQ6rmjN61R79yafy844RLepJY6kanMUFMe1vxfps4eBdaKxpFr37HCDQ11VFrZE1vMVxWb6ZDw6K8TzEKo29Ph3e7yxs8cwzpin6yFvMk1myp9etzycWRUB1VCLM71RJA9AVrEgZsa9QtzKfQJfR3XNacVAyffLmGK9F6ztWurxBxKKTZLuNV1aixhTr

@HermanL0201 HermanL0201 changed the title [WIP] Implement Product Reviews Database Schema Implement Comprehensive Product Review Database Schema Jun 6, 2025
@HermanL0201
HermanL0201 marked this pull request as ready for review June 6, 2025 03:19
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.

1 participant