Documentation ¶
Index ¶
- Constants
- type AccountGorm
- type CrudGorm
- func (c *CrudGorm[t]) BulkCreate(mdl []*t) error
- func (c *CrudGorm[t]) Create(mdl *t) error
- func (c *CrudGorm[t]) DeleteById(id string) error
- func (c *CrudGorm[t]) DeleteByIds(id []string) error
- func (c *CrudGorm[t]) DoesIDExist(id string) bool
- func (c *CrudGorm[t]) GetAll() ([]*t, error)
- func (c *CrudGorm[t]) GetById(id string) (*t, error)
- func (c *CrudGorm[t]) GetWithFilterExpression(f *rql.FilterExpression, s *rql.SortExpression, ...) (data []*t, err error)
- func (c *CrudGorm[t]) GetWithFilterExpressionPaginated(f *rql.FilterExpression, p *rql.PaginationExpression, s *rql.SortExpression, ...) (data *Paginated[t], err error)
- func (c *CrudGorm[t]) IsForAccountID(id string, accountID string) bool
- func (c *CrudGorm[t]) Model() t
- func (c *CrudGorm[t]) Update(mdl *t) error
- func (c *CrudGorm[t]) WithTransaction(tx ITransaction) ICrud[t]
- type CrudTypeSense
- func (c *CrudTypeSense[t]) BulkCreate(mdl []*t) error
- func (c *CrudTypeSense[t]) Create(mdl *t) error
- func (c *CrudTypeSense[t]) DeleteById(id string) error
- func (c *CrudTypeSense[t]) DeleteByIds(id []string) error
- func (c *CrudTypeSense[t]) Document() typesense.IDocumentClient[t]
- func (c *CrudTypeSense[t]) DoesIDExist(id string) bool
- func (c *CrudTypeSense[t]) GetAll() ([]*t, error)
- func (c *CrudTypeSense[t]) GetById(id string) (*t, error)
- func (c *CrudTypeSense[t]) GetWithFilterExpression(f *rql.FilterExpression, s *rql.SortExpression, ...) (data []*t, err error)
- func (c *CrudTypeSense[t]) GetWithFilterExpressionPaginated(f *rql.FilterExpression, p *rql.PaginationExpression, s *rql.SortExpression, ...) (data *Paginated[t], err error)
- func (c *CrudTypeSense[t]) IsForAccountID(id string, accountID string) bool
- func (c *CrudTypeSense[t]) Model() t
- func (c *CrudTypeSense[t]) Search() typesense.ISearchClient[t]
- func (c *CrudTypeSense[t]) Update(mdl *t) error
- func (c *CrudTypeSense[t]) WithTransaction(tx ITransaction) ICrud[t]
- type GormTransaction
- type HashAccountVerification
- type IAccount
- type ICrud
- type IHashVerificationAccount
- type IReadOnly
- type ISession
- type ITransaction
- type IWriteOnly
- type Paginated
- type SessionGorm
Constants ¶
const (
GormBatchSize = 3000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountGorm ¶
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 ¶
BulkCreate : create many
func (*CrudGorm[t]) DeleteById ¶
DeleteById : perma delete model by id
func (*CrudGorm[t]) DeleteByIds ¶
func (*CrudGorm[t]) DoesIDExist ¶
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 (*CrudGorm[t]) WithTransaction ¶
func (c *CrudGorm[t]) WithTransaction(tx ITransaction) ICrud[t]
type CrudTypeSense ¶
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 ¶
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 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 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