db

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: GPL-3.0 Imports: 20 Imported by: 8

Documentation

Overview

Package db handles database queries for the metadata server

Index

Constants

View Source
const (
	SQLite      = "sqlite3"
	MySQL       = "mysql"
	PostgresSQL = "postgres"
	CockroachDB = "cockroachdb"
)
View Source
const (
	// BackendLocal is used for local libraries
	BackendLocal = iota
	// BackendRclone is used for Rclone remotes
	BackendRclone
)
View Source
const (
	MediaTypeMovie = iota
	MediaTypeSeries
	MediaTypeOtherMovie
)

Defines various mediatypes, only Movie and Series support atm.

View Source
const InMemory = "sqlite3://:memory:"

Variables

This section is empty.

Functions

func AddLibrary

func AddLibrary(lib *Library) error

AddLibrary adds a filesystem folder and starts tracking media inside the folders.

func CollectMovieInfo

func CollectMovieInfo(movie *Movie)

CollectMovieInfo ensures that all relevant information for a movie is loaded this can include stream information (audio/video/subtitle tracks) and personalized playstate information.

func CreateEpisode added in v0.3.0

func CreateEpisode(episode *Episode)

CreateEpisode writes an episode to the db.

func CreateSeries

func CreateSeries(series *Series)

CreateSeries persists a series in the database.

func CreateStream

func CreateStream(stream *Stream)

CreateStream persists a stream object in the database.

func DeleteEpisode added in v0.3.0

func DeleteEpisode(episodeID uint) error

DeleteEpisode deletes an Episode

func DeleteLibraryByID added in v0.3.3

func DeleteLibraryByID(libraryID uint) error

DeleteLibrary deletes a library from the database.

func DeleteMovieByID added in v0.3.3

func DeleteMovieByID(movieID uint) error

DeleteMovieByID deletes the movie from the database

func DeletePlayState added in v0.3.0

func DeletePlayState(mediaUUID string, userID uint) error

func DeleteSeason added in v0.3.0

func DeleteSeason(seasonID uint) error

DeleteSeason deletes a Season

func DeleteSeries added in v0.3.0

func DeleteSeries(seriesID uint) error

DeleteSeries deletes a Series

func EpisodeFileExists

func EpisodeFileExists(filePath string) bool

EpisodeFileExists checks whether there already is a EpisodeFile present with the given path.

func GetEpisodeCount added in v0.4.0

func GetEpisodeCount() (int32, error)

GetEpisodeCount returns the number of episodes in the database

func GetMovieCount added in v0.4.0

func GetMovieCount() (int32, error)

GetMovieCount returns the number of movies in the database

func GetSeasonCount added in v0.4.0

func GetSeasonCount() (int32, error)

GetSeasonCount returns the number of seasons in the database

func GetSeriesCount added in v0.4.0

func GetSeriesCount() (int32, error)

GetSeriesCount returns the number of series in the database

func ItemsWithMissingMetadata

func ItemsWithMissingMetadata() []string

ItemsWithMissingMetadata fetches series with missing metadata.

func MovieFileExists

func MovieFileExists(filePath string) bool

MovieFileExists checks whether there already is a EpisodeFile present with the given path.

func NewDb

func NewDb(options DatabaseOptions) *gorm.DB

NewDb initializes a new database instance.

func NewInMemoryDBForTests added in v0.3.3

func NewInMemoryDBForTests(logMode bool)

func SaveEpisode added in v0.3.0

func SaveEpisode(episode *Episode) error

SaveEpisode updates an episode in the database.

func SaveEpisodeFile added in v0.3.0

func SaveEpisodeFile(episodeFile *EpisodeFile) error

SaveEpisodeFile updates an episodeFile in the database.

func SaveLibrary added in v0.3.0

func SaveLibrary(lib *Library)

SaveLibrary persists a library object in the database.

func SaveMovie added in v0.3.0

func SaveMovie(movie *Movie) error

SaveMovie updates a movie in the database.

func SaveMovieFile added in v0.3.0

func SaveMovieFile(movieFile *MovieFile)

SaveMovieFile saves a MovieFile

func SavePlayState added in v0.3.0

func SavePlayState(playState *PlayState) error

func SaveSeason added in v0.3.0

func SaveSeason(season *Season) error

SaveSeason updates a season in the database.

func SaveSeries added in v0.3.0

func SaveSeries(series *Series) error

SaveSeries updates a series in the database.

func UnwatchedEpisodesInSeasonCount

func UnwatchedEpisodesInSeasonCount(seasonID uint, userID uint) uint

UnwatchedEpisodesInSeasonCount retrieves the amount of unwatched episodes in a given season.

func UnwatchedEpisodesInSeriesCount

func UnwatchedEpisodesInSeriesCount(seriesID uint, userID uint) uint

UnwatchedEpisodesInSeriesCount retrieves the amount of unwatched episodes in a given series.

func UpdateAllStreams

func UpdateAllStreams()

UpdateAllStreams updates all streams for all mediaItems

func UpdateStreams

func UpdateStreams(mediaUUID string) bool

UpdateStreams deletes stream information and rescans the file

func UserCount

func UserCount() int

UserCount counts the amount of users in the db.

Types

type BackendType added in v0.2.0

type BackendType int

BackendType specifies what kind of Library backend is being used.

type BaseItem

type BaseItem struct {
	UUIDable
	TmdbID       int
	Overview     string `gorm:"type:text"`
	BackdropPath string
	PosterPath   string
}

type CommonModelFields

type CommonModelFields struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at"`
}

CommonModelFields is a list of all fields that should be present on all models.

type DatabaseOptions added in v0.3.3

type DatabaseOptions struct {
	Connection string
	LogMode    bool
}

DatabaseOptions holds information about how the database instance should be initialized

type Episode

type Episode struct {
	gorm.Model
	BaseItem
	Name         string
	SeasonNum    int
	EpisodeNum   int
	SeasonID     uint
	AirDate      string
	StillPath    string
	Season       *Season
	EpisodeFiles []EpisodeFile
}

Episode holds metadata information about episodes.

func FindAllEpisodes added in v0.3.0

func FindAllEpisodes() ([]*Episode, error)

func FindEpisodeByID added in v0.3.0

func FindEpisodeByID(id uint) (*Episode, error)

FindEpisodeByID finds a episode based on its ID

func FindEpisodeByNumber added in v0.3.0

func FindEpisodeByNumber(season *Season, episodeNum int) (*Episode, error)

FindEpisodeByNumber finds an Episode by Season/episode number

func FindEpisodeByUUID

func FindEpisodeByUUID(uuid string) (*Episode, error)

FindEpisodeByUUID finds a episode based on it's UUID.

func FindEpisodesForSeason

func FindEpisodesForSeason(seasonID uint) (episodes []Episode)

FindEpisodesForSeason finds all episodes for the given season ID.

func FindEpisodesInLibrary

func FindEpisodesInLibrary(libraryID uint) (episodes []Episode)

FindEpisodesInLibrary returns all episodes in the given library.

func GetNextEpisodes added in v0.4.0

func GetNextEpisodes(episodeUuid string, limit int32) ([]Episode, error)

GetNextEpisodes returns the next n episodes after the episode with the provided UUID

func GetPreviousEpisodes added in v0.4.0

func GetPreviousEpisodes(episodeUuid string, limit int32) ([]Episode, error)

GetPreviousEpisodes returns the next n episodes after the episode with the provided UUID

func RecentlyAddedEpisodes

func RecentlyAddedEpisodes(userID uint) (eps []*Episode)

RecentlyAddedEpisodes returns a list of the latest 10 episodes added to the database.

func UpNextEpisodes

func UpNextEpisodes(userID uint) []*Episode

UpNextEpisodes returns a list of episodes that are up for viewing next. If you recently finished episode 5 of series Y and episode 6 is unwatched it should return this episode.

func (*Episode) GetSeason

func (ep *Episode) GetSeason() *Season

GetSeason returns the associated season

func (*Episode) GetSeries

func (ep *Episode) GetSeries() *Series

GetSeries returns the associated series through season

func (*Episode) TimeStamp

func (ep *Episode) TimeStamp() int64

TimeStamp returns a unix timestamp for the given episode.

func (*Episode) UpdatedAtTimeStamp

func (ep *Episode) UpdatedAtTimeStamp() int64

UpdatedAtTimeStamp returns a unix timestamp for the given episode.

type EpisodeFile

type EpisodeFile struct {
	gorm.Model
	MediaItem
	EpisodeID uint
	Episode   *Episode
	Streams   []Stream `gorm:"polymorphic:Owner;"`
}

EpisodeFile holds filesystem information about a given episode file.

func FindAllEpisodeFiles

func FindAllEpisodeFiles() (files []EpisodeFile)

FindAllEpisodeFiles retrieves all episodefiles from the db.

func FindAllUnidentifiedEpisodeFiles added in v0.3.0

func FindAllUnidentifiedEpisodeFiles(qd *QueryDetails) ([]EpisodeFile, error)

FindAllUnidentifiedEpisodeFiles find all EpisodeFiles without an associated Episode

func FindAllUnidentifiedEpisodeFilesInLibrary added in v0.3.0

func FindAllUnidentifiedEpisodeFilesInLibrary(libraryID uint) ([]*EpisodeFile, error)

FindAllUnidentifiedEpisodeFilesInLibrary find all EpisodeFiles without an associated Episode in a library

func FindEpisodeFileByPath added in v0.3.3

func FindEpisodeFileByPath(filePath filesystem.Node) (*EpisodeFile, error)

FindEpisodeFileByPath Returns the first EpisodeFile matching the provided filePath, regardless of whether the EpisodeFile is local or remote.

func FindEpisodeFileByUUID added in v0.3.0

func FindEpisodeFileByUUID(uuid string) (*EpisodeFile, error)

FindEpisodeFileByUUID finds an EpisodeFile by UUID

func FindEpisodeFilesInLibrary added in v0.3.0

func FindEpisodeFilesInLibrary(libraryID uint) ([]EpisodeFile, error)

FindEpisodeFilesInLibrary finds all episode files in the given library.

func FindEpisodeFilesInLibraryByLocator added in v0.3.3

func FindEpisodeFilesInLibraryByLocator(libraryID uint, locator filesystem.FileLocator) (episodes []EpisodeFile)

FindEpisodeFilesInLibraryByLocator finds all episode files in the given library under the given locator's path

func (EpisodeFile) DeleteWithStreams added in v0.3.3

func (file EpisodeFile) DeleteWithStreams()

DeleteWithStreams deletes the episode file and any stale metadata information that might have resulted.

func (EpisodeFile) GetFileName added in v0.2.0

func (file EpisodeFile) GetFileName() string

GetFileName is a wrapper for the MediaFile interface

func (EpisodeFile) GetFilePath added in v0.2.0

func (file EpisodeFile) GetFilePath() string

GetFilePath is a wrapper for the MediaFile interface

func (EpisodeFile) GetLibrary added in v0.2.0

func (file EpisodeFile) GetLibrary() *Library

GetLibrary is a wrapper for the MediaFile interface

func (EpisodeFile) GetStreams added in v0.2.0

func (file EpisodeFile) GetStreams() []Stream

GetStreams returns all streams for this file

func (*EpisodeFile) IsSingleFile

func (file *EpisodeFile) IsSingleFile() bool

IsSingleFile returns true if this is the only file for the given episode.

type Invite

type Invite struct {
	gorm.Model
	Code   string
	UserID uint
	User   *User
}

Invite is a model used to invite users to your server.

func AllInvites

func AllInvites() (invites []Invite)

AllInvites returns all invites from the db.

func CreateInvite

func CreateInvite() Invite

CreateInvite creates an invite code that can be redeemed by new users.

type Library

type Library struct {
	gorm.Model
	Kind               MediaType
	Backend            int
	RcloneName         string
	FilePath           string `gorm:"unique_index:idx_file_path"`
	Name               string
	Healthy            bool `gorm:"default:'1'"`
	RefreshStartedAt   time.Time
	RefreshCompletedAt time.Time
}

Library is a struct containing information about filesystem folders.

func AllLibraries

func AllLibraries() []Library

AllLibraries returns all libraries from the database.

func FindLibrary

func FindLibrary(id int) Library

FindLibrary finds a library.

func (*Library) IsLocal added in v0.2.0

func (lib *Library) IsLocal() bool

IsLocal returns true when a library is based on a local filesystem

func (*Library) IsRclone added in v0.2.0

func (lib *Library) IsRclone() bool

IsRclone returns true when a library is based on a rclone remote

func (*Library) LogFields

func (lib *Library) LogFields() log.Fields

LogFields defines some standard fields to include in logs.

type MediaFile added in v0.2.0

type MediaFile interface {
	GetFilePath() string
	GetFileName() string
	GetLibrary() *Library
	GetStreams() []Stream
}

MediaFile is an interface for various methods can be done on both episodes and movies

func FindContentByUUID

func FindContentByUUID(uuid string) MediaFile

FindContentByUUID can retrieve episode or movie data based on a UUID.

type MediaItem

type MediaItem struct {
	UUIDable
	FileName  string
	FilePath  string
	Size      int64
	Library   Library
	LibraryID uint
}

MediaItem is an embeddeable struct that holds information about filesystem files (episode or movies).

type MediaType

type MediaType int

MediaType describes the type of media in a library.

type Movie

type Movie struct {
	gorm.Model
	BaseItem
	Title         string
	Year          uint64
	ReleaseDate   string
	OriginalTitle string
	ImdbID        string
	MovieFiles    []MovieFile
}

Movie is used to store movie metadata information.

func FindAllMovies

func FindAllMovies(qd *QueryDetails) (movies []Movie)

FindAllMovies finds all identified movies including all associated information like streams and files.

func FindMovieByID added in v0.3.0

func FindMovieByID(id uint) (*Movie, error)

FindMovieByID finds the movie specified by the given ID.

func FindMovieByTmdbID added in v0.3.0

func FindMovieByTmdbID(tmdbID int) (*Movie, error)

FindMovieByTmdbID finds the movie specified by the given TMDB ID

func FindMovieByUUID

func FindMovieByUUID(uuid string) (*Movie, error)

FindMovieByUUID finds the movie specified by the given uuid.

func FindMovieForMovieFile added in v0.3.0

func FindMovieForMovieFile(movieFile *MovieFile) (*Movie, error)

FindMovieForMovieFile accepts a movieFile and returns the movie

func FindMoviesForMDRefresh

func FindMoviesForMDRefresh() (movies []Movie)

FindMoviesForMDRefresh finds all movies, including unidentified ones.

func FindMoviesInLibrary

func FindMoviesInLibrary(libraryID uint) (movies []Movie)

FindMoviesInLibrary finds movies that have files in a certain library

func FirstMovie

func FirstMovie() Movie

FirstMovie gets the first movie out of the database (used in tests).

func RecentlyAddedMovies

func RecentlyAddedMovies(userID uint) (movies []*Movie)

RecentlyAddedMovies returns a list of the latest 10 movies added to the database.

func SearchMovieByTitle

func SearchMovieByTitle(name string) (movies []Movie)

SearchMovieByTitle search movies by title.

func UpNextMovies

func UpNextMovies(userID uint) (movies []*Movie)

UpNextMovies returns a list of movies that are recently added and not watched yet.

func (*Movie) LogFields

func (movie *Movie) LogFields() log.Fields

LogFields defines some standard items to log in debug messages.

func (*Movie) TimeStamp

func (movie *Movie) TimeStamp() int64

TimeStamp returns a unix timestamp.

func (*Movie) UpdatedAtTimeStamp

func (movie *Movie) UpdatedAtTimeStamp() int64

UpdatedAtTimeStamp returns a unix timestamp.

func (*Movie) YearAsString

func (movie *Movie) YearAsString() string

YearAsString returns the year, as a string....

type MovieFile

type MovieFile struct {
	gorm.Model
	MediaItem
	Movie   Movie
	MovieID uint
	Streams []Stream `gorm:"polymorphic:Owner;"`
}

MovieFile is used to store fileinformation about a movie.

func FindAllMovieFiles

func FindAllMovieFiles() (movies []MovieFile)

FindAllMovieFiles Returns all movies, even once that could not be identified.

func FindAllUnidentifiedMovieFiles added in v0.3.0

func FindAllUnidentifiedMovieFiles(qd QueryDetails) ([]MovieFile, error)

FindAllUnidentifiedMovieFiles find all MovieFiles without an associated Movie

func FindAllUnidentifiedMovieFilesInLibrary added in v0.3.0

func FindAllUnidentifiedMovieFilesInLibrary(libraryID uint) ([]*MovieFile, error)

FindAllUnidentifiedMovieFilesInLibrary retrieves all movies without an tmdb_id in the database.

func FindFilesForMovieUUID added in v0.3.3

func FindFilesForMovieUUID(uuid string) (movieFiles []*MovieFile)

FindFilesForMovieUUID finds all movieFiles for the associated movie UUIDs

func FindMovieFileByPath added in v0.3.3

func FindMovieFileByPath(filePath filesystem.Node) (*MovieFile, error)

FindMovieFileByPath Returns the first MovieFile matching the provided filePath, regardless of whether the MovieFile is local or remote.

func FindMovieFileByUUID added in v0.3.0

func FindMovieFileByUUID(uuid string) (*MovieFile, error)

FindMovieFileByUUID finds a specific movie based on it's UUID

func FindMovieFilesByMovieID added in v0.3.3

func FindMovieFilesByMovieID(movieID uint) ([]*MovieFile, error)

func FindMovieFilesInLibrary added in v0.3.0

func FindMovieFilesInLibrary(libraryID uint) ([]MovieFile, error)

FindMovieFilesInLibrary finds all movie files in the given library.

func FindMovieFilesInLibraryByLocator added in v0.3.3

func FindMovieFilesInLibraryByLocator(libraryID uint, locator filesystem.FileLocator) (movies []MovieFile)

FindMovieFilesInLibraryByLocator finds all movie files in the provided library under the locator's path

func (MovieFile) DeleteWithStreams added in v0.3.3

func (file MovieFile) DeleteWithStreams()

DeleteWithStreams removes this file and any metadata involved for the movie.

func (MovieFile) GetFileName added in v0.2.0

func (file MovieFile) GetFileName() string

GetFileName is a wrapper for the MediaFile interface

func (MovieFile) GetFilePath added in v0.2.0

func (file MovieFile) GetFilePath() string

GetFilePath is a wrapper for the MediaFile interface

func (MovieFile) GetLibrary added in v0.2.0

func (file MovieFile) GetLibrary() *Library

GetLibrary is a wrapper for the MediaFile interface

func (MovieFile) GetStreams added in v0.2.0

func (file MovieFile) GetStreams() []Stream

GetStreams returns all streams for this file

func (*MovieFile) IsSingleFile

func (file *MovieFile) IsSingleFile() bool

IsSingleFile returns true if this is the only file for this movie.

func (*MovieFile) String

func (file *MovieFile) String() string

String returns a nice overview of the given movie file.

type PlayState

type PlayState struct {
	gorm.Model
	UUIDable
	UserID    uint `gorm:"unique_index:idx_unique_play_state_per_media"`
	Finished  bool
	Playtime  float64
	MediaUUID string `gorm:"unique_index:idx_unique_play_state_per_media"`
}

PlayState holds status information about media files, it keeps track of progress and whether or not the content has been viewed to completion.

func FindPlayState added in v0.3.0

func FindPlayState(mediaUUID string, userID uint) (*PlayState, error)

FindPlayState finds a playstate

func LatestPlayStates

func LatestPlayStates(limit uint, userID uint) []PlayState

LatestPlayStates returns playstates for content recently played for the given user.

type QueryDetails added in v0.2.0

type QueryDetails struct {
	UserID        uint
	Offset        int
	Limit         int
	SortDirection string
	SortColumn    string
}

QueryDetails specify arguments for media queries

type Season

type Season struct {
	BaseItem
	gorm.Model
	Name         string
	AirDate      string
	SeasonNumber int
	Series       *Series
	SeriesID     uint
	Episodes     []*Episode
}

Season holds metadata information about seasons.

func FindAllSeasons

func FindAllSeasons() (seasons []Season)

FindAllSeasons returns all seasons

func FindSeason

func FindSeason(seasonID uint) (*Season, error)

FindSeason finds a season by it's ID

func FindSeasonBySeasonNumber added in v0.3.0

func FindSeasonBySeasonNumber(series *Series, seasonNum int) (*Season, error)

FindSeasonBySeasonNumber gets a season by Series/season number

func FindSeasonByUUID

func FindSeasonByUUID(uuid string) (*Season, error)

FindSeasonByUUID finds the season based on it's UUID.

func FindSeasonsForSeries

func FindSeasonsForSeries(seriesID uint) (seasons []Season)

FindSeasonsForSeries retrieves all season for the given series based on it's UUID.

func (*Season) GetSeries

func (s *Season) GetSeries() *Series

GetSeries get the associated series to this eason

type Series

type Series struct {
	BaseItem
	gorm.Model
	Name         string
	FirstAirDate string
	FirstAirYear uint64
	OriginalName string
	Status       string
	Type         string
	Seasons      []*Season
}

Series holds metadata information about series.

func FindAllSeries

func FindAllSeries(qd *QueryDetails) ([]*Series, error)

FindAllSeries retrieves all identified series from the db.

func FindSeries

func FindSeries(seriesID uint) (*Series, error)

FindSeries finds a series by it's ID

func FindSeriesByTmdbID added in v0.3.0

func FindSeriesByTmdbID(tmdbID int) (*Series, error)

FindSeriesByTmdbID retrives a serie based on its TMDB ID

func FindSeriesByUUID

func FindSeriesByUUID(uuid string) (*Series, error)

FindSeriesByUUID retrives a serie based on it's UUID.

func FindSeriesForMDRefresh

func FindSeriesForMDRefresh() (series []Series)

FindSeriesForMDRefresh finds all series, including unidentified ones.

func FindSeriesInLibrary added in v0.3.0

func FindSeriesInLibrary(libraryID uint) (series []Series)

FindSeriesInLibrary finds all series belonging to an EpisodeFile in a given library.

func SearchSeriesByTitle

func SearchSeriesByTitle(name string) (series []Series)

SearchSeriesByTitle searches for series based on their name.

type Stream

type Stream struct {
	gorm.Model
	UUIDable
	OwnerID   uint
	OwnerType string

	StreamKey

	TotalDuration time.Duration

	TimeBase         *big.Rat
	TotalDurationDts int64
	// codecs string ready for DASH/HLS serving
	Codecs    string
	CodecName string
	Profile   string
	BitRate   int64
	FrameRate *big.Rat

	Width  int
	Height int

	// "audio", "video", "subtitle"
	StreamType string
	// Only relevant for audio and subtitles. Language code.
	Language string
	// User-visible string for this audio or subtitle track
	Title            string
	EnabledByDefault bool
}

func FindStreamsForMovieFileUUID added in v0.3.3

func FindStreamsForMovieFileUUID(uuid string) (streams []*Stream)

FindStreamsForMovieFileUUID finds all movieStreams for the associated movieFile UUIDs

type StreamKey added in v0.2.0

type StreamKey struct {
	FileLocator filesystem.FileLocator
	// StreamId from ffmpeg
	// StreamId is always 0 for transmuxing
	StreamId int64
}

These are copies of the same structs in the ffmpeg package to a) avoid a dependency of the db package on the ffmpeg package and b) allow the ffmpeg package to be advanced separately from the database.

type UUIDable

type UUIDable struct {
	UUID string `json:"uuid"`
}

UUIDable ensures a UUID is added to each model this is embedded in.

func (*UUIDable) BeforeCreate

func (ud *UUIDable) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate ensures a UUID is set before model creation.

func (*UUIDable) GetUUID

func (ud *UUIDable) GetUUID() string

GetUUID returns the model's UUID.

func (*UUIDable) SetUUID

func (ud *UUIDable) SetUUID() error

SetUUID creates a new v4 UUID.

type User

type User struct {
	UUIDable
	CommonModelFields
	Username     string `gorm:"not null;unique" json:"username"`
	Admin        bool   `gorm:"not null" json:"admin"`
	PasswordHash string `gorm:"not null" json:"-"`
	Salt         string `gorm:"not null" json:"-"`
}

User defines a user model.

func AllUsers

func AllUsers() (users []User)

AllUsers return all users from thedb.

func CreateUser

func CreateUser(username string, password string, admin bool) (User, error)

CreateUser creates a new (admin) user to allow access via the web-interface

func CreateUserWithCode

func CreateUserWithCode(username string, password string, code string) (User, error)

CreateUserWithCode creates a new user. The invite code will be ignored if no other users exist yet.

func DeleteUser

func DeleteUser(id uint) (User, error)

DeleteUser deletes the given user.

func FindUser

func FindUser(id uint) (*User, error)

FindUser returns a specific user.

func FindUserByUsername added in v0.3.0

func FindUserByUsername(username string) (*User, error)

FindUserByUsername returns a specific user.

func (*User) SetPassword

func (user *User) SetPassword(password string, salt string) string

SetPassword sets a (new) password for the given user.

func (*User) ValidPassword

func (user *User) ValidPassword(password string) bool

ValidPassword checks if the given password is valid for the user.

Directories

Path Synopsis
dialects

Jump to

Keyboard shortcuts

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