types

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 31

Documentation

Index

Constants

View Source
const (
	SQLServerType = "sqlserver"
	PostgresType  = "postgres"
	SqliteType    = "sqlite"
	MysqlType     = "mysql"
	Text          = "TEXT"
	JSONType      = "JSON"
	JSONBType     = "JSONB"
	NVarcharType  = "NVARCHAR(MAX)"
)
View Source
const PostgresTimestampFormat = "2006-01-02T15:04:05.999999"

Variables

This section is empty.

Functions

func GenericStructScan added in v1.0.20

func GenericStructScan[T any](t *T, val any) error

GenericStructScan can be set as the Scan(val) func for any json struct

func GenericStructValue added in v1.0.20

func GenericStructValue[T any](t T, defaultNull bool) (driver.Value, error)

GenericStructValue can be set as the Value() func for any json struct

Types

type JSON

type JSON json.RawMessage

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

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) MarshalJSON

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

MarshalJSON to output non base64 encoded []byte

func (*JSON) Scan

func (j *JSON) Scan(value any) error

Scan scan value into Jsonb, implements sql.Scanner interface

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 JSONMap

type JSONMap map[string]any

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

func (JSONMap) GormDBDataType

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

GormDBDataType gorm db data type

func (JSONMap) GormDataType

func (m JSONMap) GormDataType() string

GormDataType gorm common data type

func (JSONMap) GormValue

func (jm JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (JSONMap) MarshalJSON

func (m JSONMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONMap) Scan

func (m *JSONMap) Scan(val any) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSONMap) UnmarshalJSON

func (m *JSONMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type JSONQueryExpression

type JSONQueryExpression struct {
	// contains filtered or unexported fields
}

JSONQueryExpression json query expression, implements clause.Expression interface to use as querier

func JSONQuery

func JSONQuery(column string) *JSONQueryExpression

JSONQuery query column as json

func (*JSONQueryExpression) Build

func (jsonQuery *JSONQueryExpression) Build(builder clause.Builder)

Build implements clause.Expression

func (*JSONQueryExpression) Equals

func (jsonQuery *JSONQueryExpression) Equals(value any, keys ...string) *JSONQueryExpression

Keys returns clause.Expression

func (*JSONQueryExpression) HasKey

func (jsonQuery *JSONQueryExpression) HasKey(keys ...string) *JSONQueryExpression

HasKey returns clause.Expression

type JSONStringMap

type JSONStringMap map[string]string

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

func (JSONStringMap) GormDBDataType

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

GormDBDataType gorm db data type

func (JSONStringMap) GormDataType

func (m JSONStringMap) GormDataType() string

GormDataType gorm common data type

func (JSONStringMap) GormValue

func (jm JSONStringMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (JSONStringMap) MarshalJSON

func (m JSONStringMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONStringMap) Scan

func (m *JSONStringMap) Scan(val any) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSONStringMap) UnmarshalJSON

func (m *JSONStringMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONStringMap) Value

func (m JSONStringMap) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

Jump to

Keyboard shortcuts

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