datatypes

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gunzip added in v0.0.3

func Gunzip(data []byte) (resData []byte, err error)

Gunzip will unzip data and return buffer inline

Types

type ChangeEvent added in v0.0.3

type ChangeEvent[T any] struct {
	ID            string               `json:"id"`
	Timestamp     int64                `json:"timestamp"`
	MvccTimestamp string               `json:"mvccTimestamp"`
	Table         string               `json:"table"`
	Key           []string             `json:"key"`
	LocationID    *string              `json:"locationId,omitempty"`
	CompanyID     *string              `json:"companyId,omitempty"`
	UserID        *string              `json:"userId,omitempty"`
	SessionID     *string              `json:"sessionId,omitempty"`
	Version       int64                `json:"version"`
	Region        string               `json:"region"`
	Operation     ChangeEventOperation `json:"operation"`
	Before        *T                   `json:"before,omitempty"`
	After         *T                   `json:"after,omitempty"`
	Diff          []string             `json:"diff,omitempty"`
}

func (ChangeEvent[T]) GetAfter added in v0.0.3

func (c ChangeEvent[T]) GetAfter() any

func (ChangeEvent[T]) GetBefore added in v0.0.3

func (c ChangeEvent[T]) GetBefore() any

func (ChangeEvent[T]) GetCompanyID added in v0.0.6

func (c ChangeEvent[T]) GetCompanyID() *string

func (ChangeEvent[T]) GetDiff added in v0.0.6

func (c ChangeEvent[T]) GetDiff() []string

func (ChangeEvent[T]) GetID added in v0.0.6

func (c ChangeEvent[T]) GetID() string

func (ChangeEvent[T]) GetKey added in v0.0.6

func (c ChangeEvent[T]) GetKey() []string

func (ChangeEvent[T]) GetLocationID added in v0.0.6

func (c ChangeEvent[T]) GetLocationID() *string

func (ChangeEvent[T]) GetMvccTimestamp added in v0.0.6

func (c ChangeEvent[T]) GetMvccTimestamp() string

func (ChangeEvent[T]) GetOperation added in v0.0.3

func (c ChangeEvent[T]) GetOperation() ChangeEventOperation

func (ChangeEvent[T]) GetRegion added in v0.0.6

func (c ChangeEvent[T]) GetRegion() string

func (ChangeEvent[T]) GetTable added in v0.0.6

func (c ChangeEvent[T]) GetTable() string

func (ChangeEvent[T]) GetTimestamp added in v0.0.6

func (c ChangeEvent[T]) GetTimestamp() int64

func (ChangeEvent[T]) GetUserID added in v0.0.6

func (c ChangeEvent[T]) GetUserID() *string

func (ChangeEvent[T]) GetVersion added in v0.0.6

func (c ChangeEvent[T]) GetVersion() int64

func (ChangeEvent[T]) String added in v0.0.3

func (c ChangeEvent[T]) String() string

String returns a JSON stringified version of the ChangeEvent

type ChangeEventOperation added in v0.0.3

type ChangeEventOperation string
const (
	ChangeEventInsert ChangeEventOperation = "INSERT"
	ChangeEventUpdate ChangeEventOperation = "UPDATE"
	ChangeEventDelete ChangeEventOperation = "DELETE"
)

type ChangeEventPayload added in v0.0.6

type ChangeEventPayload interface {
	// GetID returns the event payload id
	GetID() string
	// GetTimestamp returns the timestamp in milliseconds when the event occurred
	GetTimestamp() int64
	// GetMvccTimestamp returns the mvcc timestamp in microseconds when the change occurred
	GetMvccTimestamp() string
	// GetTable returns the table name
	GetTable() string
	// GetKey returns an array of primary keys
	GetKey() []string
	// GetLocationID returns the location id or nil if not provided or relevant for this table
	GetLocationID() *string
	// GetCompanyID returns the company id or nil if not provided or relevant for this table
	GetCompanyID() *string
	// GetUserID returns the user id that made the change or nil if not provided or relevant for this table
	GetUserID() *string
	// GetVersion returns a monotonically increasing version number for the change version to this record
	GetVersion() int64
	// GetRegion returns the region where the change was processed
	GetRegion() string
	// GetOperation returns the ChangeEventOperation
	GetOperation() ChangeEventOperation
	// GetBefore returns the record as a ChangeEvent[T] before this change or nil if not provided
	GetBefore() any
	// GetAfter returns the record as a ChangeEvent[T] after this change or nil if not provided
	GetAfter() any
	// GetDiff returns an array of string keys of the properties that changed
	GetDiff() []string
}

type DateTime added in v0.0.3

type DateTime time.Time

func (*DateTime) MarshalJSON added in v0.0.3

func (t *DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan added in v0.0.4

func (t *DateTime) Scan(v interface{}) error

func (*DateTime) UnmarshalJSON added in v0.0.3

func (t *DateTime) UnmarshalJSON(b []byte) error

func (DateTime) Value added in v0.0.4

func (t DateTime) Value() (driver.Value, error)

type JSON

type JSON json.RawMessage

JSON defined JSON data type, need to implements driver.Valuer, sql.Scanner interface

func NewJSON

func NewJSON(kv map[string]interface{}) (JSON, error)

NewJSON returns a JSON structure from a map of key/value pairs

func NewJSONArray

func NewJSONArray() (JSON, error)

NewJSONArray returns an empty JSON array

func NewJSONObject

func NewJSONObject() (JSON, error)

NewJSONObject returns an empty JSON object

func (*JSON) Del

func (j *JSON) Del(key string) error

Del will delete the key in the JSON object

func (*JSON) Get

func (j *JSON) Get(key string) (interface{}, error)

Get will return the key value from the JSON object

func (JSON) GormDBDataType

func (JSON) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSON) GormDataType

func (JSON) GormDataType() string

GormDataType gorm common data type

func (JSON) GormValue

func (js JSON) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (*JSON) Has

func (j *JSON) Has(key string) bool

Has returns true if the key exists in the JSON object

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSON) Set

func (j *JSON) Set(key string, val interface{}) error

Set will set the key and value in the JSON object

func (JSON) String

func (j JSON) String() string

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Meta

type Meta struct {
	UserID    *string `json:"userId,omitempty"`
	SessionID *string `json:"sessionId,omitempty"`
	Version   *int64  `json:"version,omitempty"`
}

func (Meta) GormDBDataType

func (Meta) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*Meta) Scan

func (m *Meta) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Meta) Value

func (m *Meta) Value() (driver.Value, error)

Value return Meta value, implement driver.Valuer interface

type NullableNumberArray

type NullableNumberArray []float64

func (NullableNumberArray) GormDBDataType

func (NullableNumberArray) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (*NullableNumberArray) Scan

func (arr *NullableNumberArray) Scan(value interface{}) error

func (NullableNumberArray) Value

func (arr NullableNumberArray) Value() (driver.Value, error)

type NullableStringArray

type NullableStringArray []string

func (NullableStringArray) GormDBDataType

func (NullableStringArray) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (*NullableStringArray) Scan

func (arr *NullableStringArray) Scan(value interface{}) error

func (NullableStringArray) Value

func (arr NullableStringArray) Value() (driver.Value, error)

type NumberArray

type NumberArray []float64

func (NumberArray) GormDBDataType

func (NumberArray) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (*NumberArray) Scan

func (arr *NumberArray) Scan(value interface{}) error

func (NumberArray) Value

func (arr NumberArray) Value() (driver.Value, error)

type StringArray

type StringArray []string

func (StringArray) GormDBDataType

func (StringArray) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (StringArray) MarshalJSON added in v0.0.7

func (arr StringArray) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*StringArray) Scan

func (arr *StringArray) Scan(value interface{}) error

func (*StringArray) UnmarshalJSON added in v0.0.7

func (arr *StringArray) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (StringArray) Value

func (arr StringArray) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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