models

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password,omitempty" validate:"required"`
}

Auth type is a struct for authentication.

type AuthClaims

type AuthClaims struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
	jwt.StandardClaims
}

AuthClaims type is a struct for JWT Claims.

type AuthJWT

type AuthJWT struct {
	Token string `json:"token"`
}

AuthJWT type is a struct for JWT authentication.

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn type is a struct for connections.

func New

func New(db *sqlx.DB) *Conn

New connects to the database.

func (*Conn) Attach

func (c *Conn) Attach(ctx context.Context, s map[int64][]int, pivot string) error

Attach receives a map of int/[]int and attach the IDs on the given pivot table.

func (*Conn) Authenticate

func (c *Conn) Authenticate(ctx context.Context, email string) (string, error)

Authenticate authenticates the current user and returns it's info.

func (*Conn) CreateGenre

func (c *Conn) CreateGenre(ctx context.Context, g *Genre) error

CreateGenre creates a new genre.

func (*Conn) CreateKeyword

func (c *Conn) CreateKeyword(ctx context.Context, k *Keyword) error

CreateKeyword creates a new keyword.

func (*Conn) CreateRecommendation

func (c *Conn) CreateRecommendation(ctx context.Context, r *Recommendation) (int64, error)

CreateRecommendation creates a new recommendation.

func (*Conn) CreateRecommendationItem

func (c *Conn) CreateRecommendationItem(ctx context.Context, r *RecommendationItem) (int64, error)

CreateRecommendationItem creates a new recommendation item.

func (*Conn) CreateSource

func (c *Conn) CreateSource(ctx context.Context, s *Source) error

CreateSource creates a new source.

func (*Conn) CreateUser

func (c *Conn) CreateUser(ctx context.Context, u *User) error

CreateUser creates a new user.

func (*Conn) DeleteGenre

func (c *Conn) DeleteGenre(ctx context.Context, id int64) error

DeleteGenre deletes a genre by ID.

func (*Conn) DeleteKeyword

func (c *Conn) DeleteKeyword(ctx context.Context, id int64) error

DeleteKeyword deletes a keyword by ID.

func (*Conn) DeleteRecommendation

func (c *Conn) DeleteRecommendation(ctx context.Context, id int64) error

DeleteRecommendation deletes a recommendation by a given ID.

func (*Conn) DeleteRecommendationItem

func (c *Conn) DeleteRecommendationItem(ctx context.Context, id int64) error

DeleteRecommendationItem deletes a recommendation item by a given ID.

func (*Conn) DeleteSource

func (c *Conn) DeleteSource(ctx context.Context, id int64) error

DeleteSource deletes a source by a given ID.

func (*Conn) DeleteUser

func (c *Conn) DeleteUser(ctx context.Context, id int64) error

DeleteUser deletes a user by a given ID.

func (*Conn) Detach

func (c *Conn) Detach(ctx context.Context, s map[int64][]int, pivot, field string) error

Detach receives a map of int/[]int and Detach the IDs on the given pivot table.

func (*Conn) GetAuthenticationInfo

func (c *Conn) GetAuthenticationInfo(ctx context.Context, email string) (*Auth, error)

GetAuthenticationInfo retrieves info for the authenticated user.

func (*Conn) GetGenre

func (c *Conn) GetGenre(ctx context.Context, id int64) (*Genre, error)

GetGenre retrieves a genre by ID.

func (*Conn) GetGenres

func (c *Conn) GetGenres(ctx context.Context, limit int) (*GenreResult, error)

GetGenres retrieves the latest genres.

func (*Conn) GetKeyword

func (c *Conn) GetKeyword(ctx context.Context, id int64) (*Keyword, error)

GetKeyword retrieves a keyword by ID.

func (*Conn) GetKeywords

func (c *Conn) GetKeywords(ctx context.Context, limit int) (*KeywordResult, error)

GetKeywords retrieves the latest keywords.

func (*Conn) GetRecommendation

func (c *Conn) GetRecommendation(ctx context.Context, id int64) (*Recommendation, error)

GetRecommendation retrieves a recommendation by ID.

func (*Conn) GetRecommendationGenres

func (c *Conn) GetRecommendationGenres(ctx context.Context, id int64) (*GenreResult, error)

GetRecommendationGenres retrieves all genres of a given recommendation.

func (*Conn) GetRecommendationItem

func (c *Conn) GetRecommendationItem(ctx context.Context, id int64) (*RecommendationItem, error)

GetRecommendationItem retrieves a recommendation items by a given ID.

func (*Conn) GetRecommendationItemSources

func (c *Conn) GetRecommendationItemSources(ctx context.Context, id int64) (*SourceResult, error)

GetRecommendationItemSources retrieves all sources of a given recommendation item.

func (*Conn) GetRecommendationItems

func (c *Conn) GetRecommendationItems(ctx context.Context, id int64) (*RecommendationItemResult, error)

GetRecommendationItems retrieves all items of a given recommendation by ID.

func (*Conn) GetRecommendationItemsTotalRows

func (c *Conn) GetRecommendationItemsTotalRows(ctx context.Context, id int64) (float64, error)

GetRecommendationItemsTotalRows retrieves the total rows of items of a recommendation.

func (*Conn) GetRecommendationKeywords

func (c *Conn) GetRecommendationKeywords(ctx context.Context, id int64) (*KeywordResult, error)

GetRecommendationKeywords retrieves all keywords of a given recommendation.

func (*Conn) GetRecommendationTotalRows

func (c *Conn) GetRecommendationTotalRows(ctx context.Context) (int, error)

GetRecommendationTotalRows retrieves the total rows of recommendations table.

func (*Conn) GetRecommendations

func (c *Conn) GetRecommendations(ctx context.Context, offset, limit int) (*[]Recommendation, error)

GetRecommendations retrieves the latest recommendations. Receives two parameters, the database offset and limit.

func (*Conn) GetRecommendationsAdmin

func (c *Conn) GetRecommendationsAdmin(ctx context.Context) (*RecommendationResult, error)

GetRecommendationsAdmin retrieves the latest recommendations. Admin does not have filter for status.

func (*Conn) GetSearchRecommendationTotalRows

func (c *Conn) GetSearchRecommendationTotalRows(ctx context.Context, search string) (int, error)

GetSearchRecommendationTotalRows retrieves the total rows of recommendations table.

func (*Conn) GetSource

func (c *Conn) GetSource(ctx context.Context, id int64) (*Source, error)

GetSource retrieves a source by a given ID.

func (*Conn) GetSources

func (c *Conn) GetSources(ctx context.Context) (*SourceResult, error)

GetSources retrieves the latest 20 sources.

func (*Conn) GetUser

func (c *Conn) GetUser(ctx context.Context, id int64) (*User, error)

GetUser retrieves a user by a given ID.

func (*Conn) GetUsers

func (c *Conn) GetUsers(ctx context.Context) (*UserResult, error)

GetUsers retrieves the first twenty users.

func (*Conn) IsEmpty

func (c *Conn) IsEmpty(s map[int64][]int) bool

IsEmpty checks if a given map of int/[]int is empty.

func (*Conn) SearchGenre

func (c *Conn) SearchGenre(ctx context.Context, search string) (*GenreResult, error)

SearchGenre search for genres.

func (*Conn) SearchKeyword

func (c *Conn) SearchKeyword(ctx context.Context, search string) (*KeywordResult, error)

SearchKeyword search for keywords.

func (*Conn) SearchRecommendation

func (c *Conn) SearchRecommendation(ctx context.Context, offset, limit int, search string) (*[]Recommendation, error)

SearchRecommendation search for recommendations.

func (*Conn) SearchSource

func (c *Conn) SearchSource(ctx context.Context, search string) (*SourceResult, error)

SearchSource search for sources.

func (*Conn) SearchUser

func (c *Conn) SearchUser(ctx context.Context, search string) (*UserResult, error)

SearchUser search for users.

func (*Conn) Sync

func (c *Conn) Sync(ctx context.Context, s map[int64][]int, pivot, field string) error

Sync receives a map of int/[]int and sync the IDs on the given pivot table.

func (*Conn) UpdateGenre

func (c *Conn) UpdateGenre(ctx context.Context, id int64, g *Genre) error

UpdateGenre updates a genre by ID.

func (*Conn) UpdateKeyword

func (c *Conn) UpdateKeyword(ctx context.Context, id int64, k *Keyword) error

UpdateKeyword updates a keyword by ID.

func (*Conn) UpdateRecommendation

func (c *Conn) UpdateRecommendation(ctx context.Context, id int64, r *Recommendation) error

UpdateRecommendation updates a recommendation by a given ID.

func (*Conn) UpdateRecommendationItem

func (c *Conn) UpdateRecommendationItem(ctx context.Context, id int64, r *RecommendationItem) error

UpdateRecommendationItem updates a recommendation item by a given ID.

func (*Conn) UpdateSource

func (c *Conn) UpdateSource(ctx context.Context, id int64, s *Source) error

UpdateSource updates a source by a given ID.

func (*Conn) UpdateUser

func (c *Conn) UpdateUser(ctx context.Context, id int64, u *User) error

UpdateUser updates a user by a given ID.

type Genre

type Genre struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name" validate:"required"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

Genre type is a struct for genres table.

type GenreResult

type GenreResult struct {
	Data *[]Genre `json:"data"`
}

GenreResult type is a result slice for genres.

type Keyword

type Keyword struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name" validate:"required"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

Keyword type is a struct for keywords table.

type KeywordResult

type KeywordResult struct {
	Data *[]Keyword `json:"data"`
}

KeywordResult type is a result slice for keywords.

type Recommendation

type Recommendation struct {
	ID        int64     `json:"id"`
	UserID    int64     `db:"user_id" json:"user_id" validate:"required"`
	Title     string    `json:"title" validate:"required"`
	Type      int       `json:"type"`
	Body      string    `json:"body" validate:"required"`
	Poster    string    `json:"poster" validate:"required"`
	Backdrop  string    `json:"backdrop" validate:"required"`
	Status    int       `json:"status"`
	Genres    string    `json:"genres"`
	Keywords  string    `json:"keywords"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

Recommendation type is a struct for the recommendations table.

type RecommendationCreate

type RecommendationCreate struct {
	*Recommendation
	Genres   []int `json:"genres" validate:"gte=1"`
	Keywords []int `json:"keywords" validate:"gte=1"`
}

RecommendationCreate type is a struct for decode the recommendation post request.

type RecommendationGenres

type RecommendationGenres struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

RecommendationGenres type is a struct for the genre_recommendation pivot table.

type RecommendationItem

type RecommendationItem struct {
	ID               int64     `json:"id"`
	RecommendationID int64     `db:"recommendation_id" json:"recommendation_id" validate:"required,numeric"`
	Name             string    `json:"name" validate:"required"`
	TMDBID           int64     `db:"tmdb_id" json:"tmdb_id" validate:"required,numeric"`
	Year             time.Time `json:"year"`
	Overview         string    `json:"overview" validate:"required"`
	Poster           string    `json:"poster" validate:"required"`
	Backdrop         string    `json:"backdrop" validate:"required"`
	Trailer          string    `json:"trailer"`
	Commentary       string    `json:"commentary"`
	MediaType        string    `db:"media_type" json:"media_type" validate:"required"`
	Sources          string    `json:"sources"`
	CreatedAt        time.Time `db:"created_at" json:"created_at"`
	UpdatedAt        time.Time `db:"updated_at" json:"updated_at"`
}

RecommendationItem type is a struct for recommendation_items table.

type RecommendationItemCreate

type RecommendationItemCreate struct {
	*RecommendationItem
	Sources []int  `json:"sources" validate:"gte=1"`
	Year    string `json:"year" validate:"required"`
}

RecommendationItemCreate type is a struct for decode recommendation item post request.

type RecommendationItemResult

type RecommendationItemResult struct {
	Data *[]RecommendationItem `json:"data"`
}

RecommendationItemResult type is a slice of recommendation items.

type RecommendationItemSources

type RecommendationItemSources struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

RecommendationItemSources type is a struct for recommendation_item_source pivot table.

type RecommendationKeywords

type RecommendationKeywords struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

RecommendationKeywords type is a struct for the keyword_recommendation pivot table.

type RecommendationResult

type RecommendationResult struct {
	Data *[]Recommendation `json:"data"`
	*tome.Chapter
}

RecommendationResult type is a result slice for recommendations.

type Search struct {
	Query string `json:"query" validate:"required"`
	Type  int    `json:"type"`
}

Search type is a struct for search queries.

type Source

type Source struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name" validate:"required"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

Source type is a struct for sources table.

type SourceResult

type SourceResult struct {
	Data *[]Source `json:"data"`
}

SourceResult type is a slice of sources.

type User

type User struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name" validate:"required"`
	Email     string    `json:"email" validate:"required,email"`
	Password  string    `json:"password" validate:"required,min=8"`
	APIToken  uuid.UUID `db:"api_token" json:"api_token"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

User type is a struct for users table.

type UserResult

type UserResult struct {
	Data *[]User `json:"data"`
}

UserResult type is a slice of users.

Jump to

Keyboard shortcuts

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