jsontype

package
v0.1.4-dev Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSlice

type JSONSlice[T any] []T

func NewJSONSlice

func NewJSONSlice[T any](s []T) JSONSlice[T]

func (JSONSlice[T]) GormDBDataType

func (JSONSlice[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSONSlice[T]) GormDataType

func (JSONSlice[T]) GormDataType() string

GormDataType gorm common data type

func (JSONSlice[T]) GormValue

func (j JSONSlice[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (*JSONSlice[T]) Scan

func (j *JSONSlice[T]) Scan(value interface{}) error

Scan scan value into JSONType[T], implements sql.Scanner interface

func (JSONSlice[T]) Value

func (j JSONSlice[T]) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type JSONTime

type JSONTime time.Time

func (JSONTime) Format

func (t JSONTime) Format() string

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) Scan

func (t *JSONTime) Scan(value interface{}) error

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) error

func (JSONTime) Value

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

type JSONType

type JSONType[T any] struct {
	Data T
}

JSONType give a generic data type for json encoded data.

func NewJSONType

func NewJSONType[T any](data T) JSONType[T]

func (JSONType[T]) GormDBDataType

func (JSONType[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSONType[T]) GormDataType

func (JSONType[T]) GormDataType() string

GormDataType gorm common data type

func (JSONType[T]) GormValue

func (js JSONType[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (JSONType[T]) MarshalJSON

func (j JSONType[T]) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONType[T]) Scan

func (j *JSONType[T]) Scan(value interface{}) error

Scan scan value into JSONType[T], implements sql.Scanner interface

func (*JSONType[T]) UnmarshalJSON

func (j *JSONType[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONType[T]) Value

func (j JSONType[T]) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Tags

type Tags map[string]any

func BoolMapToTags

func BoolMapToTags(values map[string]bool) Tags

func IntMapToTags

func IntMapToTags(values map[string]int) Tags

func StringArrayToTags

func StringArrayToTags(values []string) Tags

func StringMapToTags

func StringMapToTags(values map[string]string) Tags

func (Tags) GetString

func (m Tags) GetString(name string) string

func (Tags) Set

func (m Tags) Set(name string, v any)

Jump to

Keyboard shortcuts

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