Documentation for rating.ts
This file defines several tables and their relationships using drizzle-orm for managing ratings and their related entities in a PostgreSQL database.
Tables
ratingLU
The ratingLU table stores lookup values for ratings.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the rating. Primary key. |
| slug | varchar | Slug for the rating. |
| canLuxury | boolean | Indicates if the rating can be applied to luxury items. Default is false. |
| canVintage | boolean | Indicates if the rating can be applied to vintage items. Default is false. |
| name | varchar | Name of the rating. |
| createdAt | timestamp | Timestamp when the rating was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the rating was last updated. Updates automatically. |
| isActive | boolean | Indicates if the rating is active. Default is true. |
| createdById | text | Identifier of the user who created the rating. References user.id. |
| updatedById | text | Identifier of the user who last updated the rating. References user.id. |
unitRating
The unitRating table stores the relationship between units and ratings.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the relationship. Primary key. |
| ratingId | integer | Identifier of the rating. References ratingLU.id. |
| unitId | varchar | Identifier of the unit. References unit.id. |
| createdAt | timestamp | Timestamp when the relationship was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the relationship was last updated. Updates automatically. |
| isActive | boolean | Indicates if the relationship is active. Default is true. |
| createdById | text | Identifier of the user who created the relationship. References user.id. |
| updatedById | text | Identifier of the user who last updated the relationship. References user.id. |
userRating
The userRating table stores the relationship between users and ratings.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the relationship. Primary key. |
| ratingId | integer | Identifier of the rating. References ratingLU.id. |
| userId | varchar | Identifier of the user. References user.id. |
| createdAt | timestamp | Timestamp when the relationship was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the relationship was last updated. Updates automatically. |
| isActive | boolean | Indicates if the relationship is active. Default is true. |
| createdById | text | Identifier of the user who created the relationship. References user.id. |
| updatedById | text | Identifier of the user who last updated the relationship. References user.id. |
Relationships
ratingRelations
Defines the relationships for the ratingLU table.
unitRatings: One-to-many relationship with theunitRatingtable.userRatings: One-to-many relationship with theuserRatingtable.
unitRatingRelations
Defines the relationships for the unitRating table.
rating: Many-to-one relationship with theratingLUtable.unit: Many-to-one relationship with theunittable.
userRatingRelations
Defines the relationships for the userRating table.
rating: Many-to-one relationship with theratingLUtable.user: Many-to-one relationship with theusertable.
Constants
RATINGS
RATING VALUES
| Slug | Can Luxury | Can Vintage | Name | Created By |
|---|---|---|---|---|
| AA | true | false | Luxury & Vintage | system |
| A | false | true | Vintage | system |
| B | false | false | Standard | system |
| C | false | false | Economy | system |
| D | false | false | Budget | system |
The RATINGS constant stores predefined rating values.
const RATINGS = [
{
slug: 'AA',
canLuxury: true,
canVintage: false,
name: 'Luxury & Vintage',
createdById: 'system',
},
{
slug: 'A',
canLuxury: false,
canVintage: true,
name: 'Vintage',
createdById: 'system',
},
{
slug: 'B',
canLuxury: false,
canVintage: false,
name: 'Standard',
createdById: 'system',
},
{
slug: 'C',
canLuxury: false,
canVintage: false,
name: 'Economy',
createdById: 'system',
},
{
slug: 'D',
canLuxury: false,
canVintage: false,
name: 'Budget',
createdById: 'system',
},
]Last updated on