repository

package
v0.0.0-...-3407765 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GormBatchSize = 3000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountGorm

type AccountGorm struct {
	CrudGorm[entity.Account]
}

AccountGorm : gorm account

func (*AccountGorm) DoesAccountExist

func (a *AccountGorm) DoesAccountExist(accountID string, oremail string) bool

func (*AccountGorm) DoesAccountExistByEmail

func (a *AccountGorm) DoesAccountExistByEmail(email string) (bool, *entity.Account)

type CrudGorm

type CrudGorm[t entity.Model] struct {
	DB     *gorm.DB
	Parser rql.ISQLFilterParser
	Sorter rql.ISQLSortParser
}

func (*CrudGorm[t]) BulkCreate

func (c *CrudGorm[t]) BulkCreate(mdl []*t) error

BulkCreate : create many

func (*CrudGorm[t]) Create

func (c *CrudGorm[t]) Create(mdl *t) error

Create : create one

func (*CrudGorm[t]) DeleteById

func (c *CrudGorm[t]) DeleteById(id string) error

DeleteById : perma delete model by id

func (*CrudGorm[t]) DeleteByIds

func (c *CrudGorm[t]) DeleteByIds(id []string) error

func (*CrudGorm[t]) DoesIDExist

func (c *CrudGorm[t]) DoesIDExist(id string) bool

func (*CrudGorm[t]) GetAll

func (c *CrudGorm[t]) GetAll() ([]*t, error)

GetAll : get all the records (db dump)

func (*CrudGorm[t]) GetById

func (c *CrudGorm[t]) GetById(id string) (*t, error)

GetById : get 1 record by id if not found should return err

func (*CrudGorm[t]) GetWithFilterExpression

func (c *CrudGorm[t]) GetWithFilterExpression(f *rql.FilterExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data []*t, err error)

GetWithFilterExpression : filter + sort a result using the rql package

func (*CrudGorm[t]) GetWithFilterExpressionPaginated

func (c *CrudGorm[t]) GetWithFilterExpressionPaginated(f *rql.FilterExpression, p *rql.PaginationExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data *Paginated[t], err error)

GetWithFilterExpressionPaginated : filter + sort a result query with pagination using the rql package

func (*CrudGorm[t]) IsForAccountID

func (c *CrudGorm[t]) IsForAccountID(id string, accountID string) bool

func (*CrudGorm[t]) Model

func (c *CrudGorm[t]) Model() t

func (*CrudGorm[t]) Update

func (c *CrudGorm[t]) Update(mdl *t) error

Update : update model

func (*CrudGorm[t]) WithTransaction

func (c *CrudGorm[t]) WithTransaction(tx ITransaction) ICrud[t]

type CrudTypeSense

type CrudTypeSense[t entity.Model] struct {
	// contains filtered or unexported fields
}

func (*CrudTypeSense[t]) BulkCreate

func (c *CrudTypeSense[t]) BulkCreate(mdl []*t) error

BulkCreate : create many

func (*CrudTypeSense[t]) Create

func (c *CrudTypeSense[t]) Create(mdl *t) error

Create : create one

func (*CrudTypeSense[t]) DeleteById

func (c *CrudTypeSense[t]) DeleteById(id string) error

DeleteById : perma delete model by id

func (*CrudTypeSense[t]) DeleteByIds

func (c *CrudTypeSense[t]) DeleteByIds(id []string) error

DeleteByIds : perma delet by many ids

func (*CrudTypeSense[t]) Document

func (c *CrudTypeSense[t]) Document() typesense.IDocumentClient[t]

func (*CrudTypeSense[t]) DoesIDExist

func (c *CrudTypeSense[t]) DoesIDExist(id string) bool

func (*CrudTypeSense[t]) GetAll

func (c *CrudTypeSense[t]) GetAll() ([]*t, error)

GetAll : get all the records (db dump)

func (*CrudTypeSense[t]) GetById

func (c *CrudTypeSense[t]) GetById(id string) (*t, error)

GetById : get 1 record by id if not found should return err

func (*CrudTypeSense[t]) GetWithFilterExpression

func (c *CrudTypeSense[t]) GetWithFilterExpression(f *rql.FilterExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data []*t, err error)

GetWithFilterExpression : filter + sort a result using the rql package

func (*CrudTypeSense[t]) GetWithFilterExpressionPaginated

func (c *CrudTypeSense[t]) GetWithFilterExpressionPaginated(f *rql.FilterExpression, p *rql.PaginationExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data *Paginated[t], err error)

GetWithFilterExpressionPaginated : filter + sort a result query with pagination using the rql package

func (*CrudTypeSense[t]) IsForAccountID

func (c *CrudTypeSense[t]) IsForAccountID(id string, accountID string) bool

func (*CrudTypeSense[t]) Model

func (c *CrudTypeSense[t]) Model() t

func (*CrudTypeSense[t]) Search

func (c *CrudTypeSense[t]) Search() typesense.ISearchClient[t]

func (*CrudTypeSense[t]) Update

func (c *CrudTypeSense[t]) Update(mdl *t) error

Update : update model

func (*CrudTypeSense[t]) WithTransaction

func (c *CrudTypeSense[t]) WithTransaction(tx ITransaction) ICrud[t]

WithTransaction : transactional pointer (make sure all your repos use the same persistence layer)

type GormTransaction

type GormTransaction struct {
	DB *gorm.DB
}

func (*GormTransaction) Begin

func (g *GormTransaction) Begin() ITransaction

func (*GormTransaction) Commit

func (g *GormTransaction) Commit() error

func (*GormTransaction) RollBack

func (g *GormTransaction) RollBack()

type HashAccountVerification

type HashAccountVerification = CrudGorm[entity.HashVerificationAccount]

type IAccount

type IAccount interface {
	ICrud[entity.Account]
	DoesAccountExist(accountID string, oremail string) bool
	DoesAccountExistByEmail(email string) (bool, *entity.Account)
}

type ICrud

type ICrud[t any] interface {
	IReadOnly[t]
	IWriteOnly[t]
	// WithTransaction : transactional pointer (make sure all your repos use the same persistence layer)
	WithTransaction(tx ITransaction) ICrud[t]
}

ICrud : crud interface if your repo is read / write

type IHashVerificationAccount

type IHashVerificationAccount interface {
	ICrud[entity.HashVerificationAccount]
}

type IReadOnly

type IReadOnly[t any] interface {
	IsForAccountID(id string, accountID string) bool

	DoesIDExist(id string) bool

	// GetById : get 1 record by id if not found should return err
	GetById(id string) (*t, error)
	// GetAll : get all the records (db dump)
	GetAll() ([]*t, error)
	// GetWithFilterExpression : filter + sort a result using the rql package
	GetWithFilterExpression(f *rql.FilterExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data []*t, err error)
	// GetWithFilterExpressionPaginated : filter + sort a result query with pagination using the rql package
	GetWithFilterExpressionPaginated(f *rql.FilterExpression, p *rql.PaginationExpression, s *rql.SortExpression, baseExpression ...*rql.FilterExpression) (data *Paginated[t], err error)
}

IReadOnly : repo that only does read operations

type ISession

type ISession interface {
	ICrud[entity.Session]
}

type ITransaction

type ITransaction interface {
	Begin() ITransaction
	Commit() error
	RollBack()
}

ITransaction : transaction object for multiple dbs

type IWriteOnly

type IWriteOnly[t any] interface {
	// Create : create one
	Create(mdl *t) error
	// BulkCreate : create many
	BulkCreate(mdl []*t) error
	// Update : update model
	Update(mdl *t) error
	// DeleteById : perma delete model by id
	DeleteById(id string) error
	// DeleteByIds : perma delet by many ids
	DeleteByIds(id []string) error
}

IWriteOnly : repo that only does write operations

type Paginated

type Paginated[t any] struct {
	CurrentPage  int64 `json:"current_page"`
	CurrentSize  int64 `json:"current_size"`
	Records      []*t  `json:"records"`
	TotalRecords int64 `json:"total_records"`
	TotalPages   int64 `json:"total_pages"`
	IsFinalPage  bool  `json:"is_final_page"`
}

Paginated : paginated result

type SessionGorm

type SessionGorm = CrudGorm[entity.Session]

SessionGorm : session gorm

Jump to

Keyboard shortcuts

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