Documentation
¶
Index ¶
- Constants
- type BaseRepository
- 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 Manager
Constants ¶
const DefaultPoolName = "__default__pool_name__"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepository ¶ added in v1.63.0
type BaseRepository[T any] interface { Svc() pool.Pool GetByID(ctx context.Context, id string) (T, error) GetLastestBy(ctx context.Context, properties map[string]any) (T, error) GetAllBy(ctx context.Context, properties map[string]any, offset, limit int) ([]T, error) Search(ctx context.Context, query *data.SearchQuery) (workerpool.JobResultPipe[[]T], error) Count(ctx context.Context) (int64, error) Save(ctx context.Context, entity T) error Delete(ctx context.Context, id string) error }
BaseRepository provides generic CRUD operations for any model type. T is the model type (e.g., *models.Room).
func NewBaseRepository ¶ added in v1.63.0
func NewBaseRepository[T data.BaseModelI]( dbPool pool.Pool, workMan workerpool.Manager, modelFactory func() T, ) BaseRepository[T]
NewBaseRepository creates a new base repository instance. modelFactory should return a pointer to a new model instance (e.g., func() *models.Room { return &models.Room{} }).
type JSONMap ¶ added in v1.63.0
JSONMap is a GORM-compatible map[string]any that stores JSONB/JSON in a DB.
func (*JSONMap) Copy ¶ added in v1.63.0
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.0
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.0
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.0
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.0
GormDBDataType returns the dialect-specific database column type.
func (*JSONMap) GormDataType ¶ added in v1.63.0
GormDataType returns the common GORM data type.
func (*JSONMap) GormValue ¶ added in v1.63.0
GormValue optimizes how values are rendered in SQL for specific dialects.
func (*JSONMap) MarshalJSON ¶ added in v1.63.0
MarshalJSON customizes the JSON encoding.
func (*JSONMap) Scan ¶ added in v1.63.0
Scan implements the sql.Scanner interface for database deserialization.
func (*JSONMap) ToProtoStruct ¶ added in v1.63.0
ToProtoStruct converts a JSONMap into a structpb.Struct safely and efficiently.
func (*JSONMap) UnmarshalJSON ¶ added in v1.63.0
UnmarshalJSON deserializes JSON into the map.
type Manager ¶ added in v1.63.0
type Manager interface {
AddPool(ctx context.Context, reference string, store pool.Pool)
RemovePool(ctx context.Context, reference string)
GetPool(ctx context.Context, reference string) pool.Pool
Close(ctx context.Context)
SaveMigration(ctx context.Context, pool pool.Pool, migrationPatches ...*migration.Patch) error
// Migrate finds missing migrations and records them in the database.
Migrate(ctx context.Context, pool pool.Pool, migrationsDirPath string, migrations ...any) error
}