data

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorIsNoRows

func ErrorIsNoRows(err error) bool

ErrorIsNoRows validate if supplied error is because of record missing in DB.

func StableSearch

func StableSearch[T any](
	ctx context.Context, workMan workerpool.Manager,
	query *SearchQuery, searchFunc func(ctx context.Context, query *SearchQuery) ([]T, error),
) (workerpool.JobResultPipe[[]T], error)

Types

type BaseModel

type BaseModel struct {
	ID          string `gorm:"type:varchar(50);primary_key"`
	CreatedAt   time.Time
	ModifiedAt  time.Time
	Version     uint           `gorm:"DEFAULT 0"`
	TenantID    string         `gorm:"type:varchar(50);index:,composite:base_tenancy"`
	PartitionID string         `gorm:"type:varchar(50);index:,composite:base_tenancy"`
	AccessID    string         `gorm:"type:varchar(50);index:,composite:base_tenancy"`
	DeletedAt   gorm.DeletedAt `sql:"index"`
}

BaseModel base table struct to be extended by other models.

func (*BaseModel) BeforeCreate

func (model *BaseModel) BeforeCreate(db *gorm.DB) error

func (*BaseModel) BeforeSave

func (model *BaseModel) BeforeSave(db *gorm.DB) error

BeforeSave Ensures we update a migrations time stamps.

func (*BaseModel) BeforeUpdate

func (model *BaseModel) BeforeUpdate(_ *gorm.DB) error

BeforeUpdate Updates time stamp every time we update status of a migration.

func (*BaseModel) CopyPartitionInfo

func (model *BaseModel) CopyPartitionInfo(parent *BaseModel)

func (*BaseModel) GenID

func (model *BaseModel) GenID(ctx context.Context)

GenID creates a new id for model if its not existent.

func (*BaseModel) GetID

func (model *BaseModel) GetID() string

func (*BaseModel) GetVersion

func (model *BaseModel) GetVersion() uint

func (*BaseModel) ValidXID

func (model *BaseModel) ValidXID(id string) bool

ValidXID Validates that the supplied string is an xid.

type BaseModelI

type BaseModelI interface {
	GetID() string
	GetVersion() uint
}

type Paginator

type Paginator struct {
	Offset int
	Limit  int

	BatchSize int
}

func (*Paginator) CanLoad

func (p *Paginator) CanLoad() bool

func (*Paginator) SetBatchSize

func (p *Paginator) SetBatchSize(batchSize int)

func (*Paginator) Stop

func (p *Paginator) Stop(loadedCount int) bool

type SearchQuery

type SearchQuery struct {
	ProfileID   string
	Query       string
	QueryFields map[string]string // We query with the value of query but use value as operator: {'id': ' = ?', 'name': ' LIKE ?', 'props': ' @@ plainto_tsquery(?)'}
	Fields      map[string]any

	Pagination *Paginator
}

func NewSearchQuery

func NewSearchQuery(query string,
	fields map[string]any,
	resultPage, resultCount int,
) *SearchQuery

Jump to

Keyboard shortcuts

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