Documentation ¶
Index ¶
- func Column(col string) columnExpression
- type BinUUID
- func (u BinUUID) Bytes() []byte
- func (u BinUUID) Equals(other BinUUID) bool
- func (BinUUID) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (BinUUID) GormDataType() string
- func (u BinUUID) IsEmpty() bool
- func (u *BinUUID) IsEmptyPtr() bool
- func (u BinUUID) IsNil() bool
- func (u *BinUUID) IsNilPtr() bool
- func (u BinUUID) Length() int
- func (u BinUUID) LengthBytes() int
- func (u *BinUUID) Scan(value interface{}) error
- func (u BinUUID) String() string
- func (u BinUUID) Value() (driver.Value, error)
- type Date
- func (date *Date) GobDecode(b []byte) error
- func (date Date) GobEncode() ([]byte, error)
- func (date Date) GormDataType() string
- func (date Date) MarshalJSON() ([]byte, error)
- func (date *Date) Scan(value interface{}) (err error)
- func (date *Date) UnmarshalJSON(b []byte) error
- func (date Date) Value() (driver.Value, error)
- type JSON
- 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 interface{}) error
- func (j JSON) String() string
- func (j *JSON) UnmarshalJSON(b []byte) error
- func (j JSON) Value() (driver.Value, error)
- type JSONArrayExpression
- type JSONMap
- 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 interface{}) 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 interface{}, keys ...string) *JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) Extract(path string) *JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) HasKey(keys ...string) *JSONQueryExpression
- func (jsonQuery *JSONQueryExpression) Likes(value interface{}, keys ...string) *JSONQueryExpression
- type JSONSetExpression
- type JSONSlice
- func (JSONSlice[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (JSONSlice[T]) GormDataType() string
- func (j JSONSlice[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr
- func (j *JSONSlice[T]) Scan(value interface{}) error
- func (j JSONSlice[T]) Value() (driver.Value, error)
- type JSONType
- func (j JSONType[T]) Data() T
- func (JSONType[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (JSONType[T]) GormDataType() string
- func (js JSONType[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr
- func (j JSONType[T]) MarshalJSON() ([]byte, error)
- func (j *JSONType[T]) Scan(value interface{}) error
- func (j *JSONType[T]) UnmarshalJSON(b []byte) error
- func (j JSONType[T]) Value() (driver.Value, error)
- type Null
- type NullBool
- type NullByte
- type NullFloat64
- type NullInt16
- type NullInt32
- type NullInt64
- type NullString
- type NullTime
- type Time
- func (Time) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (Time) GormDataType() string
- func (t Time) MarshalJSON() ([]byte, error)
- func (t *Time) Scan(src interface{}) error
- func (t Time) String() string
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() (driver.Value, error)
- type URL
- func (URL) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (URL) GormDataType() string
- func (u URL) MarshalJSON() ([]byte, error)
- func (u *URL) Scan(value interface{}) error
- func (u *URL) String() string
- func (u *URL) UnmarshalJSON(data []byte) error
- func (u URL) Value() (driver.Value, error)
- type UUID
- func (u UUID) Equals(other UUID) bool
- func (UUID) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (UUID) GormDataType() string
- func (u UUID) IsEmpty() bool
- func (u *UUID) IsEmptyPtr() bool
- func (u UUID) IsNil() bool
- func (u *UUID) IsNilPtr() bool
- func (u UUID) Length() int
- func (u *UUID) Scan(value interface{}) error
- func (u UUID) String() string
- func (u UUID) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinUUID ¶ added in v1.2.2
This datatype is similar to datatypes.UUID, major difference being that this datatype stores the uuid in the database as a binary (byte) array instead of a string. Developers may use either as per their preference.
func BinUUIDFromString ¶ added in v1.2.2
BinUUIDFromString returns the BinUUID representation of the specified uuidStr.
func NewBinUUIDv1 ¶ added in v1.2.2
func NewBinUUIDv1() BinUUID
NewBinUUIDv1 generates a uuid version 1, panics on generation failure.
func NewBinUUIDv4 ¶ added in v1.2.2
func NewBinUUIDv4() BinUUID
NewBinUUIDv4 generates a uuid version 4, panics on generation failure.
func NewNilBinUUID ¶ added in v1.2.3
func NewNilBinUUID() BinUUID
NewNilBinUUID generates a nil uuid.
func (BinUUID) Equals ¶ added in v1.2.2
Equals returns true if bytes form of BinUUID matches other, false otherwise.
func (BinUUID) GormDBDataType ¶ added in v1.2.2
GormDBDataType gorm db data type.
func (BinUUID) GormDataType ¶ added in v1.2.2
GormDataType gorm common data type.
func (BinUUID) IsEmpty ¶ added in v1.2.2
IsEmpty returns true if BinUUID is nil uuid or of zero length, false otherwise.
func (*BinUUID) IsEmptyPtr ¶ added in v1.2.2
IsEmptyPtr returns true if caller BinUUID ptr is nil or it's value is empty.
func (BinUUID) IsNil ¶ added in v1.2.2
IsNil returns true if the BinUUID is nil uuid (all zeroes), false otherwise.
func (*BinUUID) IsNilPtr ¶ added in v1.2.2
IsNilPtr returns true if caller BinUUID ptr is nil, false otherwise.
func (BinUUID) Length ¶ added in v1.2.2
Length returns the number of characters in string form of UUID.
func (BinUUID) LengthBytes ¶ added in v1.2.2
Length returns the number of characters in string form of UUID.
type Date ¶
func (Date) GormDataType ¶
GormDataType gorm common data type
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
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 ¶ added in v1.1.1
type JSONArrayExpression struct {
// contains filtered or unexported fields
}
func JSONArrayQuery ¶ added in v1.1.1
func JSONArrayQuery(column string) *JSONArrayExpression
func (*JSONArrayExpression) Build ¶ added in v1.1.1
func (json *JSONArrayExpression) Build(builder clause.Builder)
Build implements clause.Expression
func (*JSONArrayExpression) Contains ¶ added in v1.1.1
func (json *JSONArrayExpression) Contains(value interface{}, keys ...string) *JSONArrayExpression
Contains checks if column[keys] contains the value given. The keys parameter is only supported for MySQL and SQLite.
func (*JSONArrayExpression) In ¶ added in v1.2.4
func (json *JSONArrayExpression) In(value interface{}, keys ...string) *JSONArrayExpression
In checks if columns[keys] is in the array value given. This method is only supported for MySQL and SQLite.
type JSONMap ¶
type JSONMap map[string]interface{}
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 ¶ added in v1.0.7
type JSONOverlapsExpression struct {
// contains filtered or unexported fields
}
JSONOverlapsExpression JSON_OVERLAPS expression, implements clause.Expression interface to use as querier
func JSONOverlaps ¶ added in v1.0.7
func JSONOverlaps(column clause.Expression, value string) *JSONOverlapsExpression
JSONOverlaps query column as json
func (*JSONOverlapsExpression) Build ¶ added in v1.0.7
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 interface{}, keys ...string) *JSONQueryExpression
Keys returns clause.Expression
func (*JSONQueryExpression) Extract ¶ added in v1.0.7
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
func (*JSONQueryExpression) Likes ¶ added in v1.2.1
func (jsonQuery *JSONQueryExpression) Likes(value interface{}, keys ...string) *JSONQueryExpression
Likes return clause.Expression
type JSONSetExpression ¶ added in v1.1.0
type JSONSetExpression struct {
// contains filtered or unexported fields
}
JSONSetExpression json set expression, implements clause.Expression interface to use as updater
func JSONSet ¶ added in v1.1.0
func JSONSet(column string) *JSONSetExpression
JSONSet update fields of json column
func (*JSONSetExpression) Build ¶ added in v1.1.0
func (jsonSet *JSONSetExpression) Build(builder clause.Builder)
Build implements clause.Expression support mysql, sqlite and postgres
func (*JSONSetExpression) Set ¶ added in v1.1.0
func (jsonSet *JSONSetExpression) Set(path string, value interface{}) *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"))
type JSONSlice ¶ added in v1.2.0
type JSONSlice[T any] []T
JSONSlice give a generic data type for json encoded slice data.
func NewJSONSlice ¶ added in v1.2.0
func (JSONSlice[T]) GormDBDataType ¶ added in v1.2.0
GormDBDataType gorm db data type
func (JSONSlice[T]) GormDataType ¶ added in v1.2.0
GormDataType gorm common data type
type JSONType ¶ added in v1.1.0
type JSONType[T any] struct { // contains filtered or unexported fields }
JSONType give a generic data type for json encoded data.
func NewJSONType ¶ added in v1.2.0
func (JSONType[T]) Data ¶ added in v1.1.0
func (j JSONType[T]) Data() T
Data return data with generic Type T
func (JSONType[T]) GormDBDataType ¶ added in v1.1.0
GormDBDataType gorm db data type
func (JSONType[T]) GormDataType ¶ added in v1.1.0
GormDataType gorm common data type
func (JSONType[T]) MarshalJSON ¶ added in v1.1.0
MarshalJSON to output non base64 encoded []byte
func (*JSONType[T]) Scan ¶ added in v1.1.0
Scan scan value into JSONType[T], implements sql.Scanner interface
func (*JSONType[T]) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON to deserialize []byte
type Null ¶ added in v1.2.4
Null represents a value that may be null. Null implements the [Scanner] interface so it can be used as a scan destination:
var s Null[string] err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s) ... if s.Valid { // use s.V } else { // NULL value }
type NullBool ¶ added in v1.2.4
NullBool represents a bool that may be null. NullBool implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullByte ¶ added in v1.2.4
NullByte represents a byte that may be null. NullByte implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullFloat64 ¶ added in v1.2.4
NullFloat64 represents a float64 that may be null. NullFloat64 implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullInt16 ¶ added in v1.2.4
NullInt16 represents an int16 that may be null. NullInt16 implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullInt32 ¶ added in v1.2.4
NullInt32 represents an int32 that may be null. NullInt32 implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullInt64 ¶ added in v1.2.4
NullInt64 represents an int64 that may be null. NullInt64 implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type NullString ¶ added in v1.2.4
NullString represents a string that may be null. NullString implements the [Scanner] interface so it can be used as a scan destination:
var s NullString err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s) ... if s.Valid { // use s.String } else { // NULL value }
type NullTime ¶ added in v1.2.4
NullTime represents a time.Time that may be null. NullTime implements the [Scanner] interface so it can be used as a scan destination, similar to NullString.
type Time ¶ added in v1.0.4
Time is time data type.
func (Time) GormDBDataType ¶ added in v1.0.4
GormDBDataType returns gorm DB data type based on the current using database.
func (Time) GormDataType ¶ added in v1.0.4
GormDataType returns gorm common data type. This type is used for the field's column type.
func (Time) MarshalJSON ¶ added in v1.0.4
MarshalJSON implements json.Marshaler to convert Time to json serialization.
func (*Time) Scan ¶ added in v1.0.4
Scan implements sql.Scanner interface and scans value into Time,
func (*Time) UnmarshalJSON ¶ added in v1.0.4
UnmarshalJSON implements json.Unmarshaler to deserialize json data.
type URL ¶ added in v1.0.7
func (URL) GormDBDataType ¶ added in v1.0.7
func (URL) GormDataType ¶ added in v1.0.7
func (URL) MarshalJSON ¶ added in v1.0.7
func (*URL) UnmarshalJSON ¶ added in v1.0.7
type UUID ¶ added in v1.2.2
This datatype stores the uuid in the database as a string. To store the uuid in the database as a binary (byte) array, please refer to datatypes.BinUUID.
func NewUUIDv1 ¶ added in v1.2.2
func NewUUIDv1() UUID
NewUUIDv1 generates a UUID version 1, panics on generation failure.
func NewUUIDv4 ¶ added in v1.2.2
func NewUUIDv4() UUID
NewUUIDv4 generates a UUID version 4, panics on generation failure.
func (UUID) Equals ¶ added in v1.2.2
Equals returns true if string form of UUID matches other, false otherwise.
func (UUID) GormDBDataType ¶ added in v1.2.2
GormDBDataType gorm db data type.
func (UUID) GormDataType ¶ added in v1.2.2
GormDataType gorm common data type.
func (UUID) IsEmpty ¶ added in v1.2.2
IsEmpty returns true if UUID is nil UUID or of zero length, false otherwise.
func (*UUID) IsEmptyPtr ¶ added in v1.2.2
IsEmptyPtr returns true if caller UUID ptr is nil or it's value is empty.
func (UUID) IsNil ¶ added in v1.2.2
IsNil returns true if the UUID is a nil UUID (all zeroes), false otherwise.
func (*UUID) IsNilPtr ¶ added in v1.2.2
IsNilPtr returns true if caller UUID ptr is nil, false otherwise.
func (UUID) Length ¶ added in v1.2.2
Length returns the number of characters in string form of UUID.