Documentation
¶
Index ¶
- func ErrorIsNoRows(err error) bool
- func StableSearch[T any](ctx context.Context, workMan workerpool.Manager, query *SearchQuery, ...) (workerpool.JobResultPipe[[]T], error)
- type BaseModel
- func (model *BaseModel) BeforeCreate(db *gorm.DB) error
- func (model *BaseModel) BeforeSave(db *gorm.DB) error
- func (model *BaseModel) BeforeUpdate(_ *gorm.DB) error
- func (model *BaseModel) CopyPartitionInfo(parent *BaseModel)
- func (model *BaseModel) GenID(ctx context.Context)
- func (model *BaseModel) GetID() string
- func (model *BaseModel) GetVersion() uint
- func (model *BaseModel) ValidXID(id string) bool
- type BaseModelI
- type JSONMap
- func (m *JSONMap) Copy() JSONMap
- func (m *JSONMap) FromProtoStruct(s *structpb.Struct) JSONMap
- func (m *JSONMap) GetFloat(key string) float64
- func (m *JSONMap) GetString(key string) string
- func (m *JSONMap) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (m *JSONMap) GormDataType() string
- func (m *JSONMap) GormValue(_ context.Context, db *gorm.DB) clause.Expr
- func (m *JSONMap) MarshalJSON() ([]byte, error)
- func (m *JSONMap) Scan(value any) error
- func (m *JSONMap) ToProtoStruct() *structpb.Struct
- func (m *JSONMap) UnmarshalJSON(data []byte) error
- func (m *JSONMap) Update(update JSONMap) JSONMap
- func (m *JSONMap) Value() (driver.Value, error)
- type Paginator
- type SearchQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorIsNoRows ¶
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) BeforeSave ¶
BeforeSave Ensures we update a migrations time stamps.
func (*BaseModel) BeforeUpdate ¶
BeforeUpdate Updates time stamp every time we update status of a migration.
func (*BaseModel) CopyPartitionInfo ¶
func (*BaseModel) GetVersion ¶
type BaseModelI ¶
type JSONMap ¶ added in v1.63.2
JSONMap is a GORM-compatible map[string]any that stores JSONB/JSON in a DB.
func (*JSONMap) Copy ¶ added in v1.63.2
Copy returns a deep copy of the JSONMap. Nested maps and slices are recursively copied so that the returned JSONMap can be modified without affecting the original.
func (*JSONMap) FromProtoStruct ¶ added in v1.63.2
FromProtoStruct populates the JSONMap with data from a protocol buffer Struct. If the receiver is nil, a new JSONMap will be created and returned. If the input struct is nil, the receiver is returned unchanged. Returns the receiver (or a new JSONMap if receiver was nil) for method chaining.
func (*JSONMap) GetFloat ¶ added in v1.63.2
GetFloat retrieves a string value from the JSONMap by key. It returns the string and a boolean indicating if the value was found and is a string.
func (*JSONMap) GetString ¶ added in v1.63.2
GetString retrieves a string value from the JSONMap by key. It returns the string and a boolean indicating if the value was found and is a string.
func (*JSONMap) GormDBDataType ¶ added in v1.63.2
GormDBDataType returns the dialect-specific database column type.
func (*JSONMap) GormDataType ¶ added in v1.63.2
GormDataType returns the common GORM data type.
func (*JSONMap) GormValue ¶ added in v1.63.2
GormValue optimizes how values are rendered in SQL for specific dialects.
func (*JSONMap) MarshalJSON ¶ added in v1.63.2
MarshalJSON customizes the JSON encoding.
func (*JSONMap) Scan ¶ added in v1.63.2
Scan implements the sql.Scanner interface for database deserialization.
func (*JSONMap) ToProtoStruct ¶ added in v1.63.2
ToProtoStruct converts a JSONMap into a structpb.Struct safely and efficiently.
func (*JSONMap) UnmarshalJSON ¶ added in v1.63.2
UnmarshalJSON deserializes JSON into the map.
type Paginator ¶
func (*Paginator) SetBatchSize ¶
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