gorm

package
v0.0.0-...-a4f6240 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	gorm.Model
	ID           uuid.UUID `gorm:"primaryKey;type:uuid"`
	CredentialID []byte    `gorm:"type:bytea;unique;index;not null"`
	PublicKey    []byte    `gorm:"type:bytea;not null"`
	UserID       uuid.UUID `gorm:"not null"`
	User         *User     `gorm:"foreignKey:UserID`
	Status       string    `gorm:"not null"`
}

type GormCredentialRepo

type GormCredentialRepo struct {
	GormRepository[string, *Credential, *domain.Credential]
}

func NewGormCredentialRepo

func NewGormCredentialRepo(db *gorm.DB) *GormCredentialRepo

func (*GormCredentialRepo) FindByCredentialId

func (r *GormCredentialRepo) FindByCredentialId(ctx context.Context, credentialId []byte) (*domain.Credential, error)

func (*GormCredentialRepo) FindByUserID

func (r *GormCredentialRepo) FindByUserID(ctx context.Context, userID uuid.UUID) ([]*domain.Credential, error)

type GormRepository

type GormRepository[IdType comparable, GormType interface{}, ModelType interface{}] struct {
	// contains filtered or unexported fields
}

func NewGormRepository

func NewGormRepository[IdType comparable, GormType interface{}, ModelType interface{}](db *gorm.DB, toGormModel func(entity ModelType) GormType, toModel func(entity GormType) ModelType) *GormRepository[IdType, GormType, ModelType]

func (*GormRepository[IdType, GormType, ModelType]) DeleteById

func (repo *GormRepository[IdType, GormType, ModelType]) DeleteById(ctx context.Context, id IdType) error

func (*GormRepository[IdType, GormType, ModelType]) FindAll

func (repo *GormRepository[IdType, GormType, ModelType]) FindAll(ctx context.Context) ([]ModelType, error)

func (*GormRepository[IdType, GormType, ModelType]) FindById

func (repo *GormRepository[IdType, GormType, ModelType]) FindById(ctx context.Context, id IdType) (ModelType, error)

func (*GormRepository[IdType, GormType, ModelType]) Save

func (repo *GormRepository[IdType, GormType, ModelType]) Save(ctx context.Context, entity ModelType) error

func (*GormRepository[IdType, GormType, ModelType]) Update

func (repo *GormRepository[IdType, GormType, ModelType]) Update(ctx context.Context, entity ModelType) error

type GormUserRepo

type GormUserRepo struct {
	GormRepository[string, *User, *domain.User]
}

func NewGormUserRepo

func NewGormUserRepo(db *gorm.DB) *GormUserRepo

func (*GormUserRepo) ExistsUserId

func (r *GormUserRepo) ExistsUserId(ctx context.Context, userId []byte) (bool, error)

func (*GormUserRepo) FindByUserId

func (r *GormUserRepo) FindByUserId(ctx context.Context, userId []byte) (*domain.User, error)

type User

type User struct {
	gorm.Model
	ID     uuid.UUID `gorm:"primaryKey;type:uuid"`
	UserID []byte    `gorm:"type:bytea;unique;index;not null"`
	Status string    `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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