repository

package
v0.0.0-...-bd7327a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This code implements a Go package that interacts with a database and provides CRUD operations for entities. The package uses the Gorm ORM to connect to the database.

This code implements a Go package that interacts with a database and provides CRUD operations for entities. The package uses the Gorm ORM to connect to the database.

This code implements a Go package that interacts with a database and provides CRUD operations for entities. The package uses the Gorm ORM to connect to the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Playlist

type Playlist struct {
	*gorm.DB
}

The Playlist type wraps a *gorm.DB object and has nine methods: Get, Create, Update, Delete and others which provide basic CRUD functionality for the Playlist entity.

func NewPlaylist

func NewPlaylist(db *gorm.DB) *Playlist

Crates a new instance of playlist with DI.

func (*Playlist) AddSong

func (r *Playlist) AddSong(user_id uint, song_id uint, playlist_id uint) error

Add song to the playlist with specifies song ID

func (*Playlist) Create

func (r *Playlist) Create(playlist *entity.Playlist) (*entity.Playlist, error)

The Create method creates a new playlist in the database and updates the user entity that created the playlist.

func (*Playlist) Delete

func (r *Playlist) Delete(id uint) error

The Delete method deletes a playlist from the database.

func (*Playlist) Get

func (r *Playlist) Get() []entity.Playlist

The Get method retrieves all the playlists from the database.

func (*Playlist) Next

func (r *Playlist) Next(user_id uint, song_id uint, playlist_id uint) error

Play next song in the playlist

func (*Playlist) Pause

func (r *Playlist) Pause(user_id uint, song_id uint, playlist_id uint) error

Pause song with specified ID

func (*Playlist) Play

func (r *Playlist) Play(user_id uint, song_id uint, playlist_id uint) error

Play song with specified ID

func (*Playlist) Prev

func (r *Playlist) Prev(user_id uint, song_id uint, playlist_id uint) error

Play previous song in the playlist

func (*Playlist) Update

func (r *Playlist) Update(id uint, playlist *entity.Playlist) (*entity.Playlist, error)

The Update method updates an existing playlist.

type Song

type Song struct {
	*gorm.DB
}

The Song type wraps a *gorm.DB object and has four methods: Get, Create, Update, Delete which provide basic CRUD functionality for the Song entity.

func NewSong

func NewSong(db *gorm.DB) *Song

Create a new instance of song with DI.

func (*Song) Create

func (r *Song) Create(song *entity.Song) (*entity.Song, error)

The Create method creates a new song in the database.

func (*Song) Delete

func (r *Song) Delete(id uint) error

The Delete method deletes a song from the database.

func (*Song) Get

func (r *Song) Get() []entity.Song

The Get method retrieves all the songs from the database.

func (*Song) Update

func (r *Song) Update(id uint, song *entity.Song) (*entity.Song, error)

The Update method updates an existing song.

type User

type User struct {
	*gorm.DB
}

The User type wraps a *gorm.DB object and has four methods: Get, Create, Update, Delete which provide basic CRUD functionality for the User entity.

func NewUser

func NewUser(db *gorm.DB) *User

Create a new instance of user entity with DI.

func (*User) Create

func (r *User) Create(user *entity.User) (*entity.User, error)

The Create method creates a new user in the database.

func (*User) Delete

func (r *User) Delete(id uint) error

The Delete method deletes a user from the database.

func (*User) Get

func (r *User) Get() []entity.User

The Get method retrieves all the users from the database.

func (*User) Update

func (r *User) Update(id uint, user *entity.User) (*entity.User, error)

The Update method updates an existing user.

Jump to

Keyboard shortcuts

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