mysqldb

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SongTableName is table name for song entity
	SongTableName = "songs"
	// SongTable is columns for song entity
	SongTable = struct {
		ID        string
		Title     string
		Artist    string
		UpdatedAt string
		CreatedAt string
	}{
		ID:        "id",
		Title:     "title",
		Artist:    "artist",
		UpdatedAt: "updated_at",
		CreatedAt: "created_at",
	}
)

Functions

This section is empty.

Types

type Song

type Song struct {
	ID        int64     `json:"id"`
	Title     string    `json:"title" validate:"required"`
	Artist    string    `json:"artist" validate:"required"`
	UpdatedAt time.Time `json:"update_at"`
	CreatedAt time.Time `json:"created_at"`
}

Song entity

type SongRepo

SongRepo to get song data from database @mock

func NewSongRepo

func NewSongRepo(impl SongRepoImpl) SongRepo

NewSongRepo return new instance of SongRepo @ctor

type SongRepoImpl

type SongRepoImpl struct {
	dig.In
	*sql.DB `name:"mysql"`
}

SongRepoImpl is implementation song repository

func (*SongRepoImpl) Create

func (r *SongRepoImpl) Create(ctx context.Context, song *Song) (int64, error)

Create song

func (*SongRepoImpl) Delete

func (r *SongRepoImpl) Delete(ctx context.Context, opt dbkit.DeleteOption) (int64, error)

Delete song

func (*SongRepoImpl) Find

func (r *SongRepoImpl) Find(ctx context.Context, opts ...dbkit.SelectOption) (list []*Song, err error)

Find song

func (*SongRepoImpl) Patch

func (r *SongRepoImpl) Patch(ctx context.Context, song *Song, opt dbkit.UpdateOption) (int64, error)

Patch song to update field of song if available

func (*SongRepoImpl) Update

func (r *SongRepoImpl) Update(ctx context.Context, song *Song, opt dbkit.UpdateOption) (int64, error)

Update song

Jump to

Keyboard shortcuts

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