Documentation
¶
Index ¶
- func AddCollection(c *models.Collection) error
- func AddCollectionFilm(c *models.CollectionFilm) error
- func AddFilm(f *models.Film) error
- func AddPermission(code string) error
- func AddUserByTelegramID(c *models.Credentials) (*models.User, error)
- func AddUserPermissions(userID int, codes ...string) error
- func AddUserWithCredentials(c *models.Credentials) (*models.User, error)
- func CloseDB()
- func DeleteCollection(id int) error
- func DeleteCollectionFilm(c *models.CollectionFilm) error
- func DeleteFilm(id int) error
- func DeletePermissions(codes ...string) error
- func DeleteUser(id int) error
- func GetCollection(collectionID int) (*models.Collection, error)
- func GetCollectionFilm(c *models.CollectionFilm) error
- func GetCollectionFilms(c *models.CollectionFilms, input *models.FilmsQueryInput) (filters.Metadata, error)
- func GetCollections(userID int, name string, filmID int, excludeFilmID int, f filters.Filters) ([]*models.Collection, filters.Metadata, error)
- func GetDB() *sql.DB
- func GetFilm(id int) (*models.Film, error)
- func GetFilms(userID int, input *models.FilmsQueryInput) ([]models.Film, filters.Metadata, error)
- func GetIdFromRefreshToken(refreshToken string) (int, error)
- func GetUserById(id int) (*models.User, error)
- func GetUserByTelegramID(telegramID int) (*models.User, error)
- func GetUserByUsername(username string) (*models.User, error)
- func GetUsers() ([]*models.User, error)
- func IsRefreshTokenRevoked(refreshToken string) (bool, error)
- func IsUsernameExists(username string) bool
- func OpenDB()
- func PingDB() error
- func RevokeRefreshToken(refreshToken string) error
- func SaveRefreshToken(refreshToken string, userID int, expiresAt time.Time) error
- func UpdateCollection(c *models.Collection) error
- func UpdateCollectionFilm(c *models.CollectionFilm) error
- func UpdateFilm(film *models.Film) error
- func UpdateUser(u *models.User) error
- type Permissions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCollection ¶
func AddCollection(c *models.Collection) error
AddCollection inserts a new collection into the collections table.
func AddCollectionFilm ¶
func AddCollectionFilm(c *models.CollectionFilm) error
AddCollectionFilm adds a film to a collection.
func AddFilm ¶
AddFilm inserts a new film into the database and returns its ID, creation, and update timestamps.
func AddPermission ¶
AddPermission inserts a new permission into the permissions table.
func AddUserByTelegramID ¶
func AddUserByTelegramID(c *models.Credentials) (*models.User, error)
AddUserByTelegramID inserts a new user with telegram_id and username into the database.
func AddUserPermissions ¶
AddUserPermissions adds multiple permissions for a specific user.
func AddUserWithCredentials ¶
func AddUserWithCredentials(c *models.Credentials) (*models.User, error)
AddUserWithCredentials inserts a new user with a username and password into the database.
func DeleteCollection ¶
DeleteCollection removes a collection by its ID.
func DeleteCollectionFilm ¶
func DeleteCollectionFilm(c *models.CollectionFilm) error
DeleteCollectionFilm removes a film from a collection by collection ID and film ID.
func DeletePermissions ¶
DeletePermissions deletes permission codes.
func DeleteUser ¶
DeleteUser removes a user from the database by their ID.
func GetCollection ¶
func GetCollection(collectionID int) (*models.Collection, error)
GetCollection retrieves a collection by its ID.
func GetCollectionFilm ¶
func GetCollectionFilm(c *models.CollectionFilm) error
GetCollectionFilm retrieves the association of a film in a collection by collection ID and film ID.
func GetCollectionFilms ¶
func GetCollectionFilms(c *models.CollectionFilms, input *models.FilmsQueryInput) (filters.Metadata, error)
GetCollectionFilms retrieves all films in a collection with optional pagination and sorting.
func GetCollections ¶
func GetCollections(userID int, name string, filmID int, excludeFilmID int, f filters.Filters) ([]*models.Collection, filters.Metadata, error)
GetCollections retrieves collections for a user with optional filtering and pagination.
func GetIdFromRefreshToken ¶
GetIdFromRefreshToken retrieves the user ID associated with a refresh token.
func GetUserById ¶
GetUserById retrieves a user by their ID.
func GetUserByTelegramID ¶
GetUserByTelegramID retrieves a user by their telegram ID.
func GetUserByUsername ¶
GetUserByUsername retrieves a user by their username.
func IsRefreshTokenRevoked ¶
IsRefreshTokenRevoked checks if a refresh token has been revoked.
func IsUsernameExists ¶
func OpenDB ¶
func OpenDB()
OpenDB opens a PostgreSQL database connection and applies any pending migrations. It initializes a connection using the DSN from `config.Dsn`, verifies the connection with a ping, and applies migrations if a path is specified in `config.Migrations`.
func RevokeRefreshToken ¶
RevokeRefreshToken marks a refresh token as revoked in the database.
func SaveRefreshToken ¶
SaveRefreshToken stores a refresh token, its associated user ID, and its expiration time in the database.
func UpdateCollection ¶
func UpdateCollection(c *models.Collection) error
UpdateCollection updates an existing collection's details.
func UpdateCollectionFilm ¶
func UpdateCollectionFilm(c *models.CollectionFilm) error
UpdateCollectionFilm updates the association of a film in a collection.
func UpdateFilm ¶
UpdateFilm updates the details of an existing film.
func UpdateUser ¶
UpdateUser updates a user's details based on their ID and version.
Types ¶
type Permissions ¶
type Permissions []string
Permissions represents a slice of permission codes.
func GetUserPermissions ¶
func GetUserPermissions(userID int) (Permissions, error)
GetUserPermissions retrieves all permission codes for a specific user.
func (Permissions) Include ¶
func (p Permissions) Include(code string) bool
Include checks if a given permission code is present in the Permissions slice.