Documentation ¶
Index ¶
- Constants
- func DbNameFromConnection(conn string) string
- func IDString(id uint64) string
- func NullTime(val *time.Time) sql.NullTime
- func ParseUint(id string) (uint64, error)
- func String(val *string) string
- func TimePtr(val Time) *time.Time
- func Validate(m interface{}) error
- type ID
- func (v ID) Invalid() bool
- func (v ID) IsZero() bool
- func (v ID) MarshalJSON() ([]byte, error)
- func (v *ID) Reset()
- func (v *ID) Scan(value any) error
- func (v *ID) Set(val string) error
- func (v ID) String() string
- func (v ID) UInt64() uint64
- func (v *ID) UnmarshalJSON(data []byte) error
- func (v ID) Valid() bool
- func (v ID) Value() (driver.Value, error)
- type IDArray
- type Metadata
- type NULLString
- type SQL
- type Scanner
- type Strings
- type Time
- func (ns Time) Add(after time.Duration) Time
- func (ns Time) IsNil() bool
- func (ns Time) IsZero() bool
- func (ns Time) MarshalJSON() ([]byte, error)
- func (ns Time) Ptr() *time.Time
- func (ns *Time) Scan(value interface{}) error
- func (ns Time) String() string
- func (ns Time) UTC() time.Time
- func (ns Time) UnixMilli() int64
- func (ns *Time) UnmarshalJSON(data []byte) error
- func (ns Time) Value() (driver.Value, error)
- type Validator
Constants ¶
const ( MaxLenForName = 64 MaxLenForEmail = 160 MaxLenForShortURL = 256 )
Max values, common for strings
Variables ¶
This section is empty.
Functions ¶
func DbNameFromConnection ¶
DbNameFromConnection return DB name from connection
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID defines a type to convert between internal uint64 and external string representations of ID
func (ID) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*ID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.
type IDArray ¶
type IDArray []ID
IDArray defines a list of IDArray
type Metadata ¶
Metadata de/encodes the string map to/from a SQL string.
type NULLString ¶
type NULLString string
NULLString de/encodes the string a SQL string.
func (*NULLString) Scan ¶
func (ns *NULLString) Scan(value interface{}) error
Scan implements the Scanner interface.
type SQL ¶
type SQL interface { // QueryContext executes a query that returns rows, typically a SELECT. // The args are for any placeholder parameters in the query. QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) // QueryRowContext executes a query that is expected to return at most one row. // QueryRowContext always returns a non-nil value. Errors are deferred until // Row's Scan method is called. // If the query selects no rows, the *Row's Scan will return ErrNoRows. // Otherwise, the *Row's Scan scans the first selected row and discards // the rest. QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row // ExecContext executes a query without returning any rows. // The args are for any placeholder parameters in the query. ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) }
SQL provides interface for Db operations
type Strings ¶
type Strings []string
Strings de/encodes the string slice to/from a SQL string.
type Time ¶
Time implements sql.Time functionality and always returns UTC
func FromUnixMilli ¶
FromUnixMilli returns Time from Unix milliseconds elapsed since January 1, 1970 UTC.
func (Time) IsNil ¶
IsNil reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
func (Time) IsZero ¶
IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. The time is a quoted string in RFC 3339 format, with sub-second precision added if present.
func (Time) String ¶
String returns string in RFC3339 format, if it's Zero time, an empty string is returned
func (Time) UnixMilli ¶
UnixMilli returns t as a Unix time, the number of milliseconds elapsed since January 1, 1970 UTC.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.