model

package
v0.0.0-...-e9cad45 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKeywordsRelation

func CreateKeywordsRelation(playlistID int, wordList []Keyword) error

CreateKeywordsRelation Execute one single SQL instruction relating existing keywords from the database with a unique Playlist.

func CreateSession

func CreateSession(s Session) error

CreateSession stores in the database the created session for further database validation

func CreateVideosFromPlaylist

func CreateVideosFromPlaylist(playlistID int, vs []Video) error

CreateVideosFromPlaylist insert into the database all the videos inserted with the playlist. Returns only nil or the error received from the database.

func DeleteSessionBySessionID

func DeleteSessionBySessionID(sessionID string) error

DeleteSessionBySessionID erase from the database the Session by it's session ID string.

func DeleteVideo

func DeleteVideo(v Video) bool

DeleteVideo deletes a video from the database. For it to work, it must be part of a specific playlist. Returns ok if entry was found and deleted without problems.

Types

type Auth

type Auth struct {
	PlaylistID int    `json:"playlistid,omitempty"`
	PublicID   string `json:"publicid,omitempty"`
	Passphrase string `json:"passphrase,omitempty"`
}

Auth type holds the information given by the user to authenticate into a specific playlist.

type Error

type Error struct {
	ErrorCode   int    `json:"code"`
	Description string `json:"description"`
}

Error represent a instance of a error that ocurred at some point in the application.

type Keyword

type Keyword struct {
	ID   int    `json:"id"`
	Word string `json:"keyword"`
}

Keyword represent a single keyword database object with his own ID.

func CreateKeyword

func CreateKeyword(word string) (Keyword, error)

CreateKeyword creates a new keyword in the database if it doesn't exist already. If exists, returns the word itself from the database.

func GetKeywordsByID

func GetKeywordsByID(ids []int) ([]Keyword, error)

GetKeywordsByID Given a slice of id's, this will return a list a keywords with all keyword from such slice.

func GetKeywordsByPartialWord

func GetKeywordsByPartialWord(partWord string) ([]Keyword, error)

GetKeywordsByPartialWord returns a list of keyword with a maximum amount of 10.

func GetKeywordsByPlaylistID

func GetKeywordsByPlaylistID(playlistID int) ([]Keyword, error)

GetKeywordsByPlaylistID get all keywords that are associated with a given Playlist

type Playlist

type Playlist struct {
	ID         int       `json:"id,omitempty"`
	PublicID   string    `json:"publicid,omitempty"`
	Name       string    `json:"name,omitempty"`
	IsPublic   bool      `json:"public,omitempty"`
	Passphrase string    `json:"passphrase,omitempty"`
	Keywords   []Keyword `json:"keywords,omitempty"`
	Videos     []Video   `json:"videos,omitempty"`
}

Playlist represent a single playlist to be created or reproduced

func CreatePlaylist

func CreatePlaylist(playlist Playlist) (Playlist, error)

CreatePlaylist create a new playlist, either public or private

func GetPlaylistByPublicID

func GetPlaylistByPublicID(publicID string) (Playlist, error)

GetPlaylistByPublicID returns a single playlist including all it's videos and keywords.

func GetPublicPlaylistsByLimitAndOffset

func GetPublicPlaylistsByLimitAndOffset(limit int, offset int) ([]Playlist, error)

GetPublicPlaylistsByLimitAndOffset given a limit and offset, returns a list of PUBLIC playlists from the database

type Session

type Session struct {
	PlaylistID int
	SessionID  string
}

Session is the structure of a valid session in the database or cookie

func GetSessionBySessionID

func GetSessionBySessionID(id string) (Session, error)

GetSessionBySessionID get the session from their base64 string

type Video

type Video struct {
	ID         int    `json:"id,omitempty"`
	PlaylistID int    `json:"playlistid,omitempty"`
	Name       string `json:"name"`
	Link       string `json:"link"`
	UniqueID   string `json:"uniqueid,omitempty"`
}

Video refers to a video, which is a part of a playlist

func CreateVideoInPlaylist

func CreateVideoInPlaylist(v Video) (Video, bool)

CreateVideoInPlaylist Creates a video in the database including it's relation with the playlist to which the video belongs.

func GetVideosByPlaylistID

func GetVideosByPlaylistID(playlistID int) ([]Video, error)

GetVideosByPlaylistID retrieve all videos that belong to a specific playlist using the id from the database.

Jump to

Keyboard shortcuts

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