models

package
v0.0.0-...-95d8b4f Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        int       `json:"id"`
	UserID    int       `json:"user_id"`
	UserName  string    `json:"user_name"`
	MovieID   int       `json:"movie_id,omitempty"`
	Comment   string    `json:"comment"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"commented_at"`
}

model for comment

type DbModel

type DbModel struct {
	Db *sql.DB
}

databse structure

func (*DbModel) CheckGenre

func (m *DbModel) CheckGenre(Genreid int) (bool, error)

func (*DbModel) CheckRating

func (m *DbModel) CheckRating(movieID, userID int) (int, error)

Check rating

func (*DbModel) DeleteGenre

func (m *DbModel) DeleteGenre(id int) error

func (*DbModel) GetAllGenres

func (m *DbModel) GetAllGenres() ([]*Genre, error)

getting all genres

func (*DbModel) GetAllMovies

func (m *DbModel) GetAllMovies() ([]*Movie, error)

func (*DbModel) GetGenreByID

func (m *DbModel) GetGenreByID(id int) (*Genre, error)

getting gerne by id

func (*DbModel) GetLatestMovies

func (m *DbModel) GetLatestMovies(userID ...int) ([]*Movie, error)

get latest Movies Featured on the website

func (*DbModel) GetMovie

func (m *DbModel) GetMovie(id int) (*Movie, error)

func (*DbModel) GetMoviesByGenre

func (m *DbModel) GetMoviesByGenre(genreID int) ([]*Movie, error)

func (*DbModel) GetUserByEmail

func (m *DbModel) GetUserByEmail(email string) (*User, error)

GetUserByEmail gets user by email

func (*DbModel) InsertGenre

func (m *DbModel) InsertGenre(Genrename string) (int, error)

func (*DbModel) InsertRating

func (m *DbModel) InsertRating(rating *Rating) (int, error)

InsertRating inserts a new rating into the database

func (*DbModel) InsertUser

func (m *DbModel) InsertUser(name, email, password string) error

func (*DbModel) UpdateGenre

func (m *DbModel) UpdateGenre(id int, GenreName string) (int, error)

func (*DbModel) UpdateRating

func (m *DbModel) UpdateRating(rating *Rating) (int, error)

UpdateRating updates a rating in the database

type Favorite

type Favorite struct {
	ID        int       `json:"id"`
	UserID    int       `json:"user_id"`
	MovieID   int       `json:"movie_id"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"fav_at"`
}

model for favorite

type Genre

type Genre struct {
	ID        int       `json:"id"`
	GenreName string    `json:"genre_name"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

Genre is the type for genre table

type Image

type Image struct {
	ID        int       `json:"id"`
	UserID    int       `json:"user_id"`
	ImagePath string    `json:"image_path"`
	ImageName string    `json:"image_name"`
	IsUsed    bool      `json:"is_used"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

model for Image

type Model

type Model struct {
	Db  DbModel
	Cld *cloudinary.Cloudinary
}

model structure- Wrapper Class for Database

func CreateModel

func CreateModel(db *sql.DB, cld *cloudinary.Cloudinary) Model

type Movie

type Movie struct {
	ID             int            `json:"id"`
	Title          string         `json:"title"`
	Description    string         `json:"description"`
	Year           int            `json:"year"`
	ReleaseDate    time.Time      `json:"release_date"`
	Runtime        int            `json:"runtime"`
	Rating         float64        `json:"rating"`
	Ratings        []Rating       `json:"ratings,omitempty"` // this is for movie details
	TotalFavorites int            `json:"total_favorites"`   // this is for movie details
	IsFavorite     bool           `json:"is_favorite"`
	Favorites      []Favorite     `json:"favorites,omitempty"`
	TotalComments  int            `json:"total_comments"`
	Comments       []Comment      `json:"comments,omitempty"` // this is for movie details
	MovieGenre     map[int]string `json:"genres"`             // this is for movie details
	Image          string         `json:"image"`
	CreatedAt      time.Time      `json:"-"`
	UpdatedAt      time.Time      `json:"-"`
}

Movie structure

type MovieFilter

type MovieFilter struct {
	FindByName    string
	FilterByGenre int
	FilterByYear  int
	OrderBy       string
}

Filter for Organising Movies

type MovieGenre

type MovieGenre struct {
	ID        int       `json:"-"`
	MovieID   int       `json:"-"`
	GenreID   int       `json:"-"`
	Genre     Genre     `json:"genre"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

MovieGenre is the type for movie genre table

type PaginatedMovies

type PaginatedMovies struct {
	TotalCount  int      `json:"total_count"`
	PerPage     int      `json:"per_page"`
	CurrentPage int      `json:"current_page"`
	Movies      []*Movie `json:"movies"`
}

Model for movies response

type QueryParam

type QueryParam struct {
	Key   string
	Value interface{}
}

query params helps to organize query parameters struct for query parameters

type Rating

type Rating struct {
	ID        int       `json:"id"`
	MovieID   int       `json:"movie_id"`
	UserID    int       `json:"user_id"`
	Rating    float32   `json:"rating"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

Structure for rating

type User

type User struct {
	ID        int       `json:"id"`
	FullName  string    `json:"full_name,omitempty"`
	Email     string    `json:"email"`
	UserType  string    `json:"user_type"`
	Password  string    `json:"password,omitempty"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

model for User

Jump to

Keyboard shortcuts

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