review

package
v0.0.0-...-7daae65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisplayNameAnonymous string = "Anonymous"
	LookupLimit          string = "REVIEW_LIMIT"
)

Variables

This section is empty.

Functions

func LoadAverageRatingAndRatingCountForProduct

func LoadAverageRatingAndRatingCountForProduct(productId int, db *gorm.DB) (float64, int)

func LoadAverageRatingForProduct

func LoadAverageRatingForProduct(productId int, db *gorm.DB) float64

func LoadTotalReviewCountForProduct

func LoadTotalReviewCountForProduct(productId int, db *gorm.DB) int

func ValidateReviewUniqueness

func ValidateReviewUniqueness(db *gorm.DB, toInsert bool) validation.RuleFunc

Types

type Review

type Review struct {
	models.BaseModelSoftDelete
	UserID     int    `gorm:"not null;index:user_review_idx" db:"user_id"`
	ProductID  int    `gorm:"not null;index:product_review_idx" db:"product_id"`
	TextReview string `gorm:"text" db:"text_review"`
	Rating     int    `gorm:"not null;" db:"rating"`
	Anonymous  bool   `gorm:"default:False;"`
}

func LoadProductReviewForUser

func LoadProductReviewForUser(productId int, userId int, db *gorm.DB) Review

func LoadReviewsForProduct

func LoadReviewsForProduct(productId int, db *gorm.DB) []Review

func LoadReviewsForProductWithLimitAndOffset

func LoadReviewsForProductWithLimitAndOffset(productId int, limit int, offset int, db *gorm.DB) []Review

func (*Review) BeforeCreate

func (toCreate *Review) BeforeCreate(db *gorm.DB) error

func (*Review) Create

func (toCreate *Review) Create(db *gorm.DB) (*gorm.DB, error)

func (*Review) Validate

func (tr *Review) Validate(db *gorm.DB, toInsert bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL