database

package
v0.1.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func ConnectDatabase

func ConnectDatabase() error

Types

type PinDTO

type PinDTO struct {
	UUID      string `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	Status    Status         `gorm:"embedded"`
	Cid       string         // `gorm:"index:cidUserId,unique"`
	Name      string
	UserID    uint // `gorm:"index:cidUserId,unique"`
}

func (*PinDTO) FromEntity

func (p *PinDTO) FromEntity(ps models.PinStatus)

func (*PinDTO) ToEntity

func (p *PinDTO) ToEntity() models.PinStatus

type PinsRepository

type PinsRepository interface {
	LockByCID(string)
	UnlockByCID(string)
	// Set adds or updates a Pin
	InsertOrGet(ctx context.Context, userID uint, pinStatus models.PinStatus) (models.PinStatus, error)
	// Patch patches the fields of a Pin according to the given ID
	Patch(ctx context.Context, userID uint, id string, fields map[string]interface{}) error
	// Get returns the Pin status for a given ID
	FindByID(ctx context.Context, userID uint, id string) (models.PinStatus, error)
	// Find returns a list of Pins for the given parameters
	Find(ctx context.Context,
		userID uint,
		cids, statuses []string,
		name string,
		before, after time.Time,
		match string,
		limit int,
	) (models.PinResults, error)
	// Delete removes the Pin according to the given ID
	Delete(ctx context.Context, userID uint, id string) error
	CIDRefrenceCount(ctx context.Context, cid string) (int64, error)
	FindByStatus(ctx context.Context, statuses []string) ([]PinDTO, error)
	ProcessByStatus(ctx context.Context, statuses []string, c chan bool) (chan *PinDTO, error)
}

Pins represents an interface to the Pins database

func GetPinsRepository

func GetPinsRepository() PinsRepository

type Status

type Status string
const (
	QUEUED  Status = "queued"
	PINNING Status = "pinning"
	PINNED  Status = "pinned"
	FAILED  Status = "failed"
)

List of Status

type User

type User struct {
	gorm.Model
	AccessToken string
}

type UsersRepository

type UsersRepository interface {
	// Set adds or updates a Pin
	Insert(ctx context.Context, token string) error
	// Patch patches the fields of a Pin according to the given ID
	Patch(ctx context.Context, id string, fields map[string]interface{}) error
	// Get returns the Pin status for a given ID
	FindByID(ctx context.Context, id string) (User, error)
	// Find returns a list of Pins for the given parameters
	FindByToken(ctx context.Context, token string) (User, error)
	// Delete removes the Pin according to the given ID
	Delete(ctx context.Context, id string) error
}

func NewUsersRepository

func NewUsersRepository() UsersRepository

Jump to

Keyboard shortcuts

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