Documentation
¶
Overview ¶
Package pg ...
Index ¶
- Variables
- func CreateExtensionQuery(extension SupportedExtension, schema string) (string, error)
- func CreateSchemaQuery(name string) (string, error)
- func CreateTypeFromEnumQuery(name string, vals ...fmt.Stringer) (string, error)
- func ErrorIs(err error, code string) bool
- func JsonbFromStringMaps(m map[string]string) postgres.Jsonb
- func NewDeleter[T any](repo *Repo, queryValFunc func(query.Query) error) *deleter[T]
- func NewDestroyer[R any](repo Repo) *destroyer[R]
- func NewErrUnknown(err error) error
- func NullInt32FromString(s string) sql.NullInt32
- func NullSerialIDFromString(id string) *int32
- func SerialIDFromString(id string) int32
- func SpanErrSkipper() errors.ErrSkipFunc
- func TimePointerToPgTime(tp *time.Time) pgtype.Time
- type CustomModel
- type DeletedAtTime
- type Err
- type FieldColumnMapper
- type Hstore
- type Jsonb
- type Model
- type NullTime
- type Point
- type Repo
- func (r *Repo) Commit() error
- func (r *Repo) CountApply(ctx context.Context, model any, q query.Query) (tx *gorm.DB)
- func (r *Repo) CountApplyWithTableName(ctx context.Context, model any, q query.Query, tableName string) (tx *gorm.DB)
- func (r *Repo) FMapper() FieldColumnMapper
- func (r *Repo) PatchApply(ctx context.Context, q query.Query, model any, toPatch map[fields.Name]any) (tx *gorm.DB)
- func (r *Repo) QueryApply(ctx context.Context, q query.Query, ops ...queryApplyOption) (tx *gorm.DB)
- func (r *Repo) QueryApplyWithTableName(ctx context.Context, q query.Query, tableName string, ops ...queryApplyOption) (tx *gorm.DB)
- func (r *Repo) Rollback() error
- type SerialModel
- type SerialModel32
- type SupportedExtension
- type Time
- type Timestamps
- type ValidPointerTimestamps
- type ValidTimestamps
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrPGMissingPGConn = errors.New("postgres connection is nil")
View Source
var System persistence.DBSystem = persistence.DBSystem(otelsemconv.DBSystemPostgreSQL.Value.AsString())
Functions ¶
func CreateExtensionQuery ¶
func CreateExtensionQuery(extension SupportedExtension, schema string) (string, error)
func CreateSchemaQuery ¶
func CreateTypeFromEnumQuery ¶
CreateTypeFromEnumQuery returns a query to create a type in a PostgresSQL DB only if the type does not already exist.
func NewDeleter ¶
func NewDestroyer ¶
func NewErrUnknown ¶
func NullInt32FromString ¶
func NullSerialIDFromString ¶
func SerialIDFromString ¶
func SpanErrSkipper ¶
func SpanErrSkipper() errors.ErrSkipFunc
Types ¶
type CustomModel ¶
type CustomModel[T any] struct { ID_ T `gorm:"column:id;"` Timestamps }
func CustomModelFromResource ¶
func CustomModelFromResource(r resource.Resource) CustomModel[string]
func Int32CustomModelFromResource ¶
func Int32CustomModelFromResource(r resource.Resource) CustomModel[int32]
func NewCustomModel ¶
func (*CustomModel[T]) ID ¶
func (d *CustomModel[T]) ID() T
type DeletedAtTime ¶
func (*DeletedAtTime) Scan ¶
func (dat *DeletedAtTime) Scan(value any) error
type FieldColumnMapper ¶
type Model ¶
type Model struct {
ID_ string `gorm:"column:id;type:uuid;default:uuid_generate_v4();primaryKey"`
Timestamps
}
func ModelFromResource ¶
type NullTime ¶
func NewNullTime ¶
type Repo ¶
func (*Repo) CountApply ¶
func (*Repo) CountApplyWithTableName ¶
func (*Repo) FMapper ¶
func (r *Repo) FMapper() FieldColumnMapper
func (*Repo) PatchApply ¶
func (*Repo) QueryApply ¶
func (*Repo) QueryApplyWithTableName ¶
type SerialModel ¶
type SerialModel struct {
ID_ int `gorm:"primaryKey;autoIncrement=false;column:id;type:serial"`
Timestamps
}
func NewSerialModel ¶
func SerialModelFromResource ¶
func SerialModelFromResource(r resource.Resource) SerialModel
func (*SerialModel) ID ¶
func (d *SerialModel) ID() string
func (*SerialModel) LID ¶
func (d *SerialModel) LID() string
type SerialModel32 ¶
type SerialModel32 struct {
ID_ int32 `gorm:"primaryKey;column:id;type:serial"`
Timestamps
}
func NewSerialModel32 ¶
func SerialModel32FromResource ¶
func SerialModel32FromResource(r resource.Resource) SerialModel32
func (*SerialModel32) ID ¶
func (d *SerialModel32) ID() string
func (*SerialModel32) LID ¶
func (d *SerialModel32) LID() string
type SupportedExtension ¶
type SupportedExtension string
type Timestamps ¶
type Timestamps struct {
CreatedAt_ Time `gorm:"column:created_at;type:timestamp;autoCreateTime:true"`
UpdatedAt_ Time `gorm:"column:updated_at;type:timestamp;autoUpdateTime:true"`
DeletedAt_ DeletedAtTime `gorm:"column:deleted_at;type:timestamp"`
}
func TimestampFromTimes ¶
func TimestampFromTimes(createdAt, updatedAt time.Time, deletedAt *time.Time) Timestamps
func (*Timestamps) CreatedAt ¶
func (t *Timestamps) CreatedAt() time.Time
func (*Timestamps) DeletedAt ¶
func (t *Timestamps) DeletedAt() *time.Time
func (*Timestamps) UpdatedAt ¶
func (t *Timestamps) UpdatedAt() time.Time
type ValidPointerTimestamps ¶
type ValidPointerTimestamps struct {
ValidSince_ Time `gorm:"column:valid_since;type:timestamp"`
ValidUpTo_ NullTime `gorm:"column:valid_up_to;type:timestamp"`
}
func NewValidPointerTimestamps ¶
func NewValidPointerTimestamps(validSince time.Time, validUpTo *time.Time) ValidPointerTimestamps
func (*ValidPointerTimestamps) ValidSince ¶
func (d *ValidPointerTimestamps) ValidSince() time.Time
func (*ValidPointerTimestamps) ValidUpTo ¶
func (d *ValidPointerTimestamps) ValidUpTo() *time.Time
type ValidTimestamps ¶
type ValidTimestamps struct {
ValidSince_ Time `gorm:"column:valid_since;type:timestamp"`
ValidUpTo_ Time `gorm:"column:valid_up_to;type:timestamp"`
}
func NewValidTimestamps ¶
func NewValidTimestamps(validSince, validUpTo time.Time) ValidTimestamps
func (*ValidTimestamps) ValidSince ¶
func (d *ValidTimestamps) ValidSince() time.Time
func (*ValidTimestamps) ValidUpTo ¶
func (d *ValidTimestamps) ValidUpTo() time.Time
Source Files
¶
Click to show internal directories.
Click to hide internal directories.