Documentation ¶
Index ¶
- func Column(col string) columnExpression
- func Unmarshal(input any, output any) error
- type JSON
- func (j JSON) Array() []gjson.Result
- func (j JSON) ForEach(iterator func(key, value gjson.Result) bool)
- func (j JSON) Get(path string) gjson.Result
- func (JSON) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (JSON) GormDataType() string
- func (js JSON) GormValue(ctx context.Context, db *gorm.DB) clause.Expr
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j *JSON) Scan(value any) error
- func (j JSON) String() string
- func (j JSON) Unmarshal(v any) error
- func (j *JSON) UnmarshalJSON(b []byte) error
- func (j JSON) Value() (driver.Value, error)
- type JSONArrayExpression
- type JSONMap
- func (j JSONMap) ForEach(iterator func(key, value gjson.Result) bool)
- func (j JSONMap) Get(path string) gjson.Result
- func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (m JSONMap) GormDataType() string
- func (jm JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr
- func (m JSONMap) MarshalJSON() ([]byte, error)
- func (m *JSONMap) Scan(val any) error
- func (m *JSONMap) UnmarshalJSON(b []byte) error
- func (m JSONMap) Value() (driver.Value, error)
- type JSONOverlapsExpression
- type JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) Build(builder clause.Builder)
- func (jsonQuery *JSONQueryExpression) Equals(value any, keys ...string) *JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) Extract(path string) *JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) HasKey(keys ...string) *JSONQueryExpression
- type JSONSetExpression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type JSON ¶
type JSON json.RawMessage
JSON defined JSON data type, need to implements driver.Valuer, sql.Scanner interface
func (JSON) GormDBDataType ¶
GormDBDataType gorm db data type
func (JSON) MarshalJSON ¶
MarshalJSON to output non base64 encoded []byte
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON to deserialize []byte
type JSONArrayExpression ¶
type JSONArrayExpression struct {
// contains filtered or unexported fields
}
func JSONArrayQuery ¶
func JSONArrayQuery(column string) *JSONArrayExpression
func (*JSONArrayExpression) Build ¶
func (json *JSONArrayExpression) Build(builder clause.Builder)
Build implements clause.Expression
func (*JSONArrayExpression) Contains ¶
func (json *JSONArrayExpression) Contains(value any) *JSONArrayExpression
type JSONMap ¶
JSONMap defined JSON data type, need to implements driver.Valuer, sql.Scanner interface
func (JSONMap) GormDBDataType ¶
GormDBDataType gorm db data type
func (JSONMap) GormDataType ¶
GormDataType gorm common data type
func (JSONMap) MarshalJSON ¶
MarshalJSON to output non base64 encoded []byte
func (*JSONMap) UnmarshalJSON ¶
UnmarshalJSON to deserialize []byte
type JSONOverlapsExpression ¶
type JSONOverlapsExpression struct {
// contains filtered or unexported fields
}
JSONOverlapsExpression JSON_OVERLAPS expression, implements clause.Expression interface to use as querier
func JSONOverlaps ¶
func JSONOverlaps(column clause.Expression, value string) *JSONOverlapsExpression
JSONOverlaps query column as json
func (*JSONOverlapsExpression) Build ¶
func (json *JSONOverlapsExpression) Build(builder clause.Builder)
Build implements clause.Expression only mysql support JSON_OVERLAPS
type JSONQueryExpression ¶
type JSONQueryExpression struct {
// contains filtered or unexported fields
}
JSONQueryExpression json query expression, implements clause.Expression interface to use as querier
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) Extract ¶
func (jsonQuery *JSONQueryExpression) Extract(path string) *JSONQueryExpression
Extract extract json with path
func (*JSONQueryExpression) HasKey ¶
func (jsonQuery *JSONQueryExpression) HasKey(keys ...string) *JSONQueryExpression
HasKey returns clause.Expression
type JSONSetExpression ¶
type JSONSetExpression struct {
// contains filtered or unexported fields
}
JSONSetExpression json set expression, implements clause.Expression interface to use as updater
func (*JSONSetExpression) Build ¶
func (jsonSet *JSONSetExpression) Build(builder clause.Builder)
Build implements clause.Expression support mysql, sqlite and postgres
func (*JSONSetExpression) Set ¶
func (jsonSet *JSONSetExpression) Set(path string, value any) *JSONSetExpression
Set return clause.Expression.
{ "age": 20, "name": "json-1", "orgs": {"orga": "orgv"}, "tags": ["tag1", "tag2"] } // In MySQL/SQLite, path is `age`, `name`, `orgs.orga`, `tags[0]`, `tags[1]`. DB.UpdateColumn("attr", JSONSet("attr").Set("orgs.orga", 42)) // In PostgreSQL, path is `{age}`, `{name}`, `{orgs,orga}`, `{tags, 0}`, `{tags, 1}`. DB.UpdateColumn("attr", JSONSet("attr").Set("{orgs, orga}", "bar"))