package datatypes

Import Path
	gorm.io/datatypes (on go.dev)

Dependency Relation
	imports 18 packages, and imported by one package


Package-Level Type Names (total 22)
/* sort by: | */
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. String returns the string form of the UUID. Equals returns true if bytes form of BinUUID matches other, false otherwise. GormDBDataType gorm db data type. GormDataType gorm common data type. IsEmpty returns true if BinUUID is nil uuid or of zero length, false otherwise. IsEmptyPtr returns true if caller BinUUID ptr is nil or it's value is empty. IsNil returns true if the BinUUID is nil uuid (all zeroes), false otherwise. IsNilPtr returns true if caller BinUUID ptr is nil, false otherwise. Length returns the number of characters in string form of UUID. Length returns the number of characters in string form of UUID. Scan is the scanner function for this datatype. String returns the string form of the UUID. Value is the valuer function for this datatype. BinUUID : gorm.io/gorm/migrator.GormDataTypeInterface BinUUID : gorm.io/gorm/schema.GormDataTypeInterface *BinUUID : database/sql.Scanner BinUUID : database/sql/driver.Valuer BinUUID : expvar.Var BinUUID : fmt.Stringer BinUUID : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice func BinUUIDFromString(uuidStr string) BinUUID func NewBinUUIDv1() BinUUID func NewBinUUIDv4() BinUUID func NewNilBinUUID() BinUUID func BinUUID.Equals(other BinUUID) bool
(*Date) GobDecode(b []byte) error ( Date) GobEncode() ([]byte, error) GormDataType gorm common data type ( Date) MarshalJSON() ([]byte, error) (*Date) Scan(value interface{}) (err error) (*Date) UnmarshalJSON(b []byte) error ( Date) Value() (driver.Value, error) Date : gorm.io/gorm/schema.GormDataTypeInterface *Date : database/sql.Scanner Date : database/sql/driver.Valuer *Date : encoding/gob.GobDecoder Date : encoding/gob.GobEncoder Date : encoding/json.Marshaler *Date : encoding/json.Unmarshaler Date : github.com/goccy/go-json.Marshaler *Date : github.com/goccy/go-json.Unmarshaler
JSON defined JSON data type, need to implements driver.Valuer, sql.Scanner interface GormDBDataType gorm db data type GormDataType gorm common data type ( JSON) GormValue(ctx context.Context, db *gorm.DB) clause.Expr MarshalJSON to output non base64 encoded []byte Scan scan value into Jsonb, implements sql.Scanner interface ( JSON) String() string UnmarshalJSON to deserialize []byte Value return json value, implement driver.Valuer interface JSON : gorm.io/gorm.Valuer JSON : gorm.io/gorm/migrator.GormDataTypeInterface JSON : gorm.io/gorm/schema.GormDataTypeInterface *JSON : database/sql.Scanner JSON : database/sql/driver.Valuer JSON : encoding/json.Marshaler *JSON : encoding/json.Unmarshaler JSON : expvar.Var JSON : fmt.Stringer JSON : github.com/goccy/go-json.Marshaler *JSON : github.com/goccy/go-json.Unmarshaler
Build implements clause.Expression Contains checks if column[keys] contains the value given. The keys parameter is only supported for MySQL and SQLite. In checks if columns[keys] is in the array value given. This method is only supported for MySQL and SQLite. *JSONArrayExpression : gorm.io/gorm/clause.Expression func JSONArrayQuery(column string) *JSONArrayExpression func (*JSONArrayExpression).Contains(value interface{}, keys ...string) *JSONArrayExpression func (*JSONArrayExpression).In(value interface{}, keys ...string) *JSONArrayExpression
JSONMap defined JSON data type, need to implements driver.Valuer, sql.Scanner interface GormDBDataType gorm db data type GormDataType gorm common data type ( JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr MarshalJSON to output non base64 encoded []byte Scan scan value into Jsonb, implements sql.Scanner interface UnmarshalJSON to deserialize []byte Value return json value, implement driver.Valuer interface JSONMap : gorm.io/gorm.Valuer JSONMap : gorm.io/gorm/migrator.GormDataTypeInterface JSONMap : gorm.io/gorm/schema.GormDataTypeInterface *JSONMap : database/sql.Scanner JSONMap : database/sql/driver.Valuer JSONMap : encoding/json.Marshaler *JSONMap : encoding/json.Unmarshaler JSONMap : github.com/goccy/go-json.Marshaler *JSONMap : github.com/goccy/go-json.Unmarshaler
JSONOverlapsExpression JSON_OVERLAPS expression, implements clause.Expression interface to use as querier Build implements clause.Expression only mysql support JSON_OVERLAPS *JSONOverlapsExpression : gorm.io/gorm/clause.Expression func JSONOverlaps(column clause.Expression, value string) *JSONOverlapsExpression
JSONQueryExpression json query expression, implements clause.Expression interface to use as querier Build implements clause.Expression Keys returns clause.Expression Extract extract json with path HasKey returns clause.Expression Likes return clause.Expression *JSONQueryExpression : gorm.io/gorm/clause.Expression func JSONQuery(column string) *JSONQueryExpression func (*JSONQueryExpression).Equals(value interface{}, keys ...string) *JSONQueryExpression func (*JSONQueryExpression).Extract(path string) *JSONQueryExpression func (*JSONQueryExpression).HasKey(keys ...string) *JSONQueryExpression func (*JSONQueryExpression).Likes(value interface{}, keys ...string) *JSONQueryExpression
JSONSetExpression json set expression, implements clause.Expression interface to use as updater Build implements clause.Expression support mysql, sqlite and postgres 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")) *JSONSetExpression : gorm.io/gorm/clause.Expression func JSONSet(column string) *JSONSetExpression func (*JSONSetExpression).Set(path string, value interface{}) *JSONSetExpression
Type Parameters: T: any JSONSlice give a generic data type for json encoded slice data. GormDBDataType gorm db data type GormDataType gorm common data type ( JSONSlice[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr Scan scan value into JSONType[T], implements sql.Scanner interface Value return json value, implement driver.Valuer interface JSONSlice : gorm.io/gorm.Valuer JSONSlice : gorm.io/gorm/migrator.GormDataTypeInterface JSONSlice : gorm.io/gorm/schema.GormDataTypeInterface *JSONSlice : database/sql.Scanner JSONSlice : database/sql/driver.Valuer func NewJSONSlice[T](s []T) JSONSlice[T]
Type Parameters: T: any JSONType give a generic data type for json encoded data. Data return data with generic Type T GormDBDataType gorm db data type GormDataType gorm common data type ( JSONType[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr MarshalJSON to output non base64 encoded []byte Scan scan value into JSONType[T], implements sql.Scanner interface UnmarshalJSON to deserialize []byte Value return json value, implement driver.Valuer interface JSONType : gorm.io/gorm.Valuer JSONType : gorm.io/gorm/migrator.GormDataTypeInterface JSONType : gorm.io/gorm/schema.GormDataTypeInterface *JSONType : database/sql.Scanner JSONType : database/sql/driver.Valuer JSONType : encoding/json.Marshaler *JSONType : encoding/json.Unmarshaler JSONType : github.com/goccy/go-json.Marshaler *JSONType : github.com/goccy/go-json.Unmarshaler func NewJSONType[T](data T) JSONType[T]
Type Parameters: T: any 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 } V T Valid bool (*Null[T]) Scan(value any) error ( Null[T]) Value() (driver.Value, error) *Null : database/sql.Scanner Null : database/sql/driver.Valuer func NewNull[T](v T) Null[T]
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].
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].
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].
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].
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].
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].
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 }
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].
Time is time data type. GormDBDataType returns gorm DB data type based on the current using database. GormDataType returns gorm common data type. This type is used for the field's column type. MarshalJSON implements json.Marshaler to convert Time to json serialization. Scan implements sql.Scanner interface and scans value into Time, String implements fmt.Stringer interface. UnmarshalJSON implements json.Unmarshaler to deserialize json data. Value implements driver.Valuer interface and returns string format of Time. Time : gorm.io/gorm/migrator.GormDataTypeInterface Time : gorm.io/gorm/schema.GormDataTypeInterface *Time : database/sql.Scanner Time : database/sql/driver.Valuer Time : encoding/json.Marshaler *Time : encoding/json.Unmarshaler Time : expvar.Var Time : fmt.Stringer Time : github.com/goccy/go-json.Marshaler *Time : github.com/goccy/go-json.Unmarshaler func NewTime(hour, min, sec, nsec int) Time
// append a query ('?') even if RawQuery is empty // fragment for references, without '#' // host or host:port (see Hostname and Port methods) // do not emit empty host (authority) // encoded opaque data // path (relative paths may omit leading slash) // encoded fragment hint (see EscapedFragment method) // encoded path hint (see EscapedPath method) // encoded query values, without '?' Scheme string // username and password information ( URL) GormDBDataType(db *gorm.DB, field *schema.Field) string ( URL) GormDataType() string ( URL) MarshalJSON() ([]byte, error) (*URL) Scan(value interface{}) error (*URL) String() string (*URL) UnmarshalJSON(data []byte) error ( URL) Value() (driver.Value, error) URL : gorm.io/gorm/migrator.GormDataTypeInterface URL : gorm.io/gorm/schema.GormDataTypeInterface *URL : database/sql.Scanner URL : database/sql/driver.Valuer URL : encoding/json.Marshaler *URL : encoding/json.Unmarshaler *URL : expvar.Var *URL : fmt.Stringer URL : github.com/goccy/go-json.Marshaler *URL : github.com/goccy/go-json.Unmarshaler
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. Equals returns true if string form of UUID matches other, false otherwise. GormDBDataType gorm db data type. GormDataType gorm common data type. IsEmpty returns true if UUID is nil UUID or of zero length, false otherwise. IsEmptyPtr returns true if caller UUID ptr is nil or it's value is empty. IsNil returns true if the UUID is a nil UUID (all zeroes), false otherwise. IsNilPtr returns true if caller UUID ptr is nil, false otherwise. Length returns the number of characters in string form of UUID. Scan is the scanner function for this datatype. String returns the string form of the UUID. Value is the valuer function for this datatype. UUID : gorm.io/gorm/migrator.GormDataTypeInterface UUID : gorm.io/gorm/schema.GormDataTypeInterface *UUID : database/sql.Scanner UUID : database/sql/driver.Valuer UUID : expvar.Var UUID : fmt.Stringer func NewUUIDv1() UUID func NewUUIDv4() UUID func UUID.Equals(other UUID) bool
Package-Level Functions (total 15)
BinUUIDFromString returns the BinUUID representation of the specified uuidStr.
JSONOverlaps query column as json
JSONQuery query column as json
JSONSet update fields of json column
NewBinUUIDv1 generates a uuid version 1, panics on generation failure.
NewBinUUIDv4 generates a uuid version 4, panics on generation failure.
Type Parameters: T: any
Type Parameters: T: any
NewNilBinUUID generates a nil uuid.
Type Parameters: T: any NewNull returns a new, non-null Null.
NewTime is a constructor for Time and returns new Time.
NewUUIDv1 generates a UUID version 1, panics on generation failure.
NewUUIDv4 generates a UUID version 4, panics on generation failure.