Skip to Content
File StructurePackagesDbDocumentation for rating.ts

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.

ColumnData TypeDescription
idserialUnique identifier for the rating. Primary key.
slugvarcharSlug for the rating.
canLuxurybooleanIndicates if the rating can be applied to luxury items. Default is false.
canVintagebooleanIndicates if the rating can be applied to vintage items. Default is false.
namevarcharName of the rating.
createdAttimestampTimestamp when the rating was created. Default is the current time.
updatedAttimestampTimestamp when the rating was last updated. Updates automatically.
isActivebooleanIndicates if the rating is active. Default is true.
createdByIdtextIdentifier of the user who created the rating. References user.id.
updatedByIdtextIdentifier of the user who last updated the rating. References user.id.

unitRating

The unitRating table stores the relationship between units and ratings.

ColumnData TypeDescription
idserialUnique identifier for the relationship. Primary key.
ratingIdintegerIdentifier of the rating. References ratingLU.id.
unitIdvarcharIdentifier of the unit. References unit.id.
createdAttimestampTimestamp when the relationship was created. Default is the current time.
updatedAttimestampTimestamp when the relationship was last updated. Updates automatically.
isActivebooleanIndicates if the relationship is active. Default is true.
createdByIdtextIdentifier of the user who created the relationship. References user.id.
updatedByIdtextIdentifier of the user who last updated the relationship. References user.id.

userRating

The userRating table stores the relationship between users and ratings.

ColumnData TypeDescription
idserialUnique identifier for the relationship. Primary key.
ratingIdintegerIdentifier of the rating. References ratingLU.id.
userIdvarcharIdentifier of the user. References user.id.
createdAttimestampTimestamp when the relationship was created. Default is the current time.
updatedAttimestampTimestamp when the relationship was last updated. Updates automatically.
isActivebooleanIndicates if the relationship is active. Default is true.
createdByIdtextIdentifier of the user who created the relationship. References user.id.
updatedByIdtextIdentifier 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 the unitRating table.
  • userRatings: One-to-many relationship with the userRating table.

unitRatingRelations

Defines the relationships for the unitRating table.

  • rating: Many-to-one relationship with the ratingLU table.
  • unit: Many-to-one relationship with the unit table.

userRatingRelations

Defines the relationships for the userRating table.

  • rating: Many-to-one relationship with the ratingLU table.
  • user: Many-to-one relationship with the user table.

Constants

RATINGS

RATING VALUES

SlugCan LuxuryCan VintageNameCreated By
AAtruefalseLuxury & Vintagesystem
AfalsetrueVintagesystem
BfalsefalseStandardsystem
CfalsefalseEconomysystem
DfalsefalseBudgetsystem

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