types

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTime added in v0.1.5

type DateTime time.Time

DateTime for empty date/time field

func ParseDateTime added in v0.1.5

func ParseDateTime(value string) (DateTime, error)

ParseDateTime converts string to date time

func (DateTime) AddDate added in v0.1.5

func (t DateTime) AddDate(years int, months int, days int) DateTime

AddDate adds years, months, and days to the date time

func (DateTime) After added in v0.1.5

func (t DateTime) After(u DateTime) bool

After checks if the date time is after the given date time

func (DateTime) Before added in v0.1.5

func (t DateTime) Before(u DateTime) bool

Before checks if the date time is before the given date time

func (DateTime) Equal added in v0.1.5

func (t DateTime) Equal(u DateTime) bool

Equal checks if the date time is equal to the given date time

func (DateTime) FromTime added in v0.1.5

func (t DateTime) FromTime(u time.Time) DateTime

FromTime converts time.Time to date time

func (DateTime) GoString added in v0.1.5

func (t DateTime) GoString() string

GoString returns the iso date time in Go source code format string

func (DateTime) MarshalJSON added in v0.1.5

func (t DateTime) MarshalJSON() ([]byte, error)

MarshalJSON converts iso date time to json string format

func (DateTime) Now added in v0.1.5

func (t DateTime) Now() DateTime

Now returns the current date time

func (DateTime) String added in v0.1.5

func (t DateTime) String() string

String returns the iso date time formatted using the format string

func (DateTime) Time added in v0.1.5

func (t DateTime) Time() time.Time

Time returns the date time as time.Time

func (*DateTime) UnmarshalJSON added in v0.1.5

func (t *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json string to iso date time

func (DateTime) Value added in v0.1.5

func (t DateTime) Value() (driver.Value, error)

Value converts iso date time to sql driver value

type IsoDate

type IsoDate time.Time

IsoDate struct

func MustParseIsoDate added in v0.1.5

func MustParseIsoDate(value string) IsoDate

MustParseIsoDate converts string to iso date and panics if error occurs

func ParseIsoDate

func ParseIsoDate(value string) (IsoDate, error)

ParseIsoDate converts string to iso date

func (IsoDate) AddDate added in v0.1.5

func (i IsoDate) AddDate(years int, months int, days int) IsoDate

AddDate adds years, months, and days to the iso date

func (IsoDate) After added in v0.1.5

func (i IsoDate) After(i2 IsoDate) bool

After compares two iso dates

func (IsoDate) Before added in v0.1.5

func (i IsoDate) Before(i2 IsoDate) bool

Before compares two iso dates

func (IsoDate) Compare added in v0.1.5

func (i IsoDate) Compare(i2 IsoDate) int

Compare compares two iso dates

func (IsoDate) Equal added in v0.1.5

func (i IsoDate) Equal(i2 IsoDate) bool

Equal compares two iso dates

func (IsoDate) FromDateTime added in v0.1.5

func (i IsoDate) FromDateTime(t DateTime) IsoDate

FromDateTime converts DateTime to iso date

func (IsoDate) FromTime added in v0.1.5

func (i IsoDate) FromTime(t time.Time) IsoDate

FromTime converts time.Time to iso date

func (IsoDate) GoString

func (t IsoDate) GoString() string

GoString returns the iso date in Go source code format string

func (IsoDate) IsZero added in v0.1.5

func (i IsoDate) IsZero() bool

IsZero checks if the iso date is zero

func (IsoDate) MarshalJSON

func (t IsoDate) MarshalJSON() ([]byte, error)

MarshalJSON converts iso date to json string format

func (IsoDate) String

func (t IsoDate) String() string

String returns the iso date formatted using the format string

func (IsoDate) Time added in v0.1.5

func (i IsoDate) Time() time.Time

Time returns the iso date as time.Time

func (*IsoDate) UnmarshalJSON

func (t *IsoDate) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json string to iso date

func (IsoDate) Value

func (t IsoDate) Value() (driver.Value, error)

Value converts iso date to sql driver value

type IsoTime

type IsoTime time.Time

IsoTime struct

func ParseIsoTime

func ParseIsoTime(value string) (IsoTime, error)

ParseIsoTime converts string to iso time

func (IsoTime) GoString

func (t IsoTime) GoString() string

GoString returns the iso date in Go source code format string

func (IsoTime) MarshalJSON

func (t IsoTime) MarshalJSON() ([]byte, error)

MarshalJSON converts iso time to json string format

func (IsoTime) String

func (t IsoTime) String() string

String returns the iso date formatted using the format string

func (*IsoTime) UnmarshalJSON

func (t *IsoTime) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json string to iso time

func (IsoTime) Value

func (t IsoTime) Value() (driver.Value, error)

Value converts iso time to sql driver value

type JsonB

type JsonB map[string]any

JsonB for json binary field

func (*JsonB) Scan

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

func (JsonB) Value

func (j JsonB) Value() (driver.Value, error)

type Monetary added in v0.1.5

type Monetary struct{ decimal.Decimal }

Monetary for value field

func NewMonetaryFromCents added in v0.1.5

func NewMonetaryFromCents(cents int64) Monetary

NewMonetaryFromCents creates a new Monetary from an integer cent value

func NewMonetaryFromDecimal added in v0.1.5

func NewMonetaryFromDecimal(value decimal.Decimal) Monetary

NewMonetaryFromDecimal creates a new Monetary from a decimal.Decimal

func NewMonetaryFromFloat added in v0.1.5

func NewMonetaryFromFloat(value float64) Monetary

NewMonetaryFromFloat creates a new Monetary from a float64

func ParseMonetary added in v0.1.5

func ParseMonetary(value string) (Monetary, error)

ParseMonetary converts string to monetary

func (Monetary) Add added in v0.1.5

func (m Monetary) Add(value Monetary) Monetary

Add creates a new Monetary by adding incoming value to current value

func (Monetary) Cents added in v0.1.5

func (m Monetary) Cents() int64

Cents returns the monetary value as cents (integer)

func (Monetary) Compare added in v0.1.5

func (m Monetary) Compare(value Monetary) int

Compare compares current value with incoming value

func (Monetary) Div added in v0.1.5

func (m Monetary) Div(value Monetary) Monetary

Div creates a new Monetary by dividing current value by incoming value

func (Monetary) Equal added in v0.1.5

func (m Monetary) Equal(value Monetary) bool

Equal checks if current value is equal to incoming value

func (Monetary) GreaterThanOrEqual added in v0.1.5

func (m Monetary) GreaterThanOrEqual(value Monetary) bool

GreaterThanOrEqual checks if current value is greater than or equal to incoming value

func (Monetary) LessThanOrEqual added in v0.1.5

func (m Monetary) LessThanOrEqual(value Monetary) bool

LessThanOrEqual checks if current value is less than or equal to incoming value

func (Monetary) MarshalJSON added in v0.1.5

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

MarshalJSON converts the Monetary value to a JSON string format

func (Monetary) Mul added in v0.1.5

func (m Monetary) Mul(value Monetary) Monetary

Mul creates a new Monetary by multiplying current value with incoming value

func (Monetary) Sub added in v0.1.5

func (m Monetary) Sub(value Monetary) Monetary

Sub creates a new Monetary by subtracting incoming value from current value

func (*Monetary) UnmarshalJSON added in v0.1.5

func (m *Monetary) UnmarshalJSON(data []byte) error

UnmarshalJSON converts a JSON string or float to a Monetary value

func (Monetary) Value added in v0.1.5

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

Value converts monetary value to sql driver value

type NullBool

type NullBool sql.NullBool

NullBoll for empty boolean field

func ParseNullBool added in v0.1.5

func ParseNullBool(value string) (NullBool, error)

ParseNullBool converts string to NullBool

func (NullBool) MarshalJSON

func (t NullBool) MarshalJSON() ([]byte, error)

MarshalJSON converts null bool to json bool format

func (*NullBool) Scan

func (t *NullBool) Scan(value any) error

Scan converts sql driver value to null bool

func (*NullBool) UnmarshalJSON

func (t *NullBool) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json bool to null bool

func (NullBool) Value

func (n NullBool) Value() (driver.Value, error)

Value converts null bool to sql driver value

type NullDateTime

type NullDateTime sql.NullTime

NullDateTime for empty date/time field

func ParseNullDateTime added in v0.1.5

func ParseNullDateTime(value string) (NullDateTime, error)

ParseNullDateTime converts string to NullDateTime

func (NullDateTime) MarshalJSON

func (t NullDateTime) MarshalJSON() ([]byte, error)

MarshalJSON converts null date time to json date time format

func (*NullDateTime) Scan

func (t *NullDateTime) Scan(value any) error

Scan converts sql driver value to null date time

func (*NullDateTime) UnmarshalJSON

func (t *NullDateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json date time to null date time

func (NullDateTime) Value

func (n NullDateTime) Value() (driver.Value, error)

Value converts null date time to sql driver value

type NullFloat64

type NullFloat64 sql.NullFloat64

NullFloat64 for empty float field

func ParseNullFloat64 added in v0.1.5

func ParseNullFloat64(value string) (NullFloat64, error)

ParseNullFloat64 converts string to NullFloat64

func (NullFloat64) MarshalJSON

func (t NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON converts null float64 to json float64 format

func (*NullFloat64) Scan

func (t *NullFloat64) Scan(value any) error

Scan converts sql driver value to null float64

func (*NullFloat64) UnmarshalJSON

func (t *NullFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json float64 to null float64

func (NullFloat64) Value

func (n NullFloat64) Value() (driver.Value, error)

Value converts null float64 to sql driver value

type NullInt16

type NullInt16 sql.NullInt16

NullInt16 for empty int16 field

func ParseNullInt16 added in v0.1.5

func ParseNullInt16(value string) (NullInt16, error)

ParseNullInt16 converts string to NullInt16

func (NullInt16) MarshalJSON

func (t NullInt16) MarshalJSON() ([]byte, error)

MarshalJSON converts null int16 to json int16 format

func (*NullInt16) Scan

func (t *NullInt16) Scan(value any) error

Scan converts sql driver value to null int16

func (*NullInt16) UnmarshalJSON

func (t *NullInt16) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json int16 to null int16

func (NullInt16) Value

func (n NullInt16) Value() (driver.Value, error)

Value converts null int16 to sql driver value

type NullInt32

type NullInt32 sql.NullInt32

NullInt32 for empty int32 field

func ParseNullInt32 added in v0.1.5

func ParseNullInt32(value string) (NullInt32, error)

ParseNullInt32 converts string to int32

func (NullInt32) MarshalJSON

func (t NullInt32) MarshalJSON() ([]byte, error)

MarshalJSON converts null int32 to json int32 format

func (*NullInt32) Scan

func (t *NullInt32) Scan(value any) error

Scan converts sql driver value to null int32

func (*NullInt32) UnmarshalJSON

func (t *NullInt32) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json int32 to null int32

func (NullInt32) Value

func (n NullInt32) Value() (driver.Value, error)

Value converts null int32 to sql driver value

type NullInt64

type NullInt64 sql.NullInt64

NullInt64 for empty int64 field

func ParseNullInt64 added in v0.1.5

func ParseNullInt64(value string) (NullInt64, error)

ParseNullInt64 converts string to int64

func (NullInt64) MarshalJSON

func (t NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON converts null int64 to json int64 format

func (*NullInt64) Scan

func (t *NullInt64) Scan(value any) error

Scan converts sql driver value to null int64

func (*NullInt64) UnmarshalJSON

func (t *NullInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json int64 to null int64

func (NullInt64) Value

func (n NullInt64) Value() (driver.Value, error)

Value converts null int64 to sql driver value

type NullIsoDate

type NullIsoDate sql.NullTime

NullIsoDate for empty date field

func ParseNullIsoDate added in v0.1.5

func ParseNullIsoDate(value string) (NullIsoDate, error)

ParseNullIsoDate converts string to NullIsoDate

func (NullIsoDate) MarshalJSON

func (t NullIsoDate) MarshalJSON() ([]byte, error)

MarshalJSON converts null iso date to json iso date format

func (*NullIsoDate) Scan

func (t *NullIsoDate) Scan(value any) error

Scan converts sql driver value to null iso date

func (*NullIsoDate) UnmarshalJSON

func (t *NullIsoDate) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json iso date to null iso date

func (NullIsoDate) Value

func (t NullIsoDate) Value() (driver.Value, error)

Value converts null iso date to sql driver value

type NullIsoTime

type NullIsoTime sql.NullTime

NullIsoTime for empty time field

func ParseNullIsoTime added in v0.1.5

func ParseNullIsoTime(value string) (NullIsoTime, error)

ParseNullIsoTime converts string to NullIsoTime

func (NullIsoTime) MarshalJSON

func (t NullIsoTime) MarshalJSON() ([]byte, error)

MarshalJSON converts null iso time to json iso time format

func (*NullIsoTime) Scan

func (t *NullIsoTime) Scan(value any) error

Scan converts sql driver value to null iso time

func (*NullIsoTime) UnmarshalJSON

func (t *NullIsoTime) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json iso time to null iso time

func (NullIsoTime) Value

func (t NullIsoTime) Value() (driver.Value, error)

Value converts null iso time to sql driver value

type NullJsonB added in v0.1.5

type NullJsonB map[string]any

NullJsonB for empty jsonb field

func (*NullJsonB) Scan added in v0.1.5

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

Scan converts sql driver value to null jsonb

func (NullJsonB) Value added in v0.1.5

func (j NullJsonB) Value() (driver.Value, error)

Value converts null jsonb to sql driver value

type NullString

type NullString sql.NullString

NullString for empty string field

func (NullString) MarshalJSON

func (t NullString) MarshalJSON() ([]byte, error)

MarshalJSON converts null string to json string format

func (*NullString) Scan

func (t *NullString) Scan(value any) error

Scan converts sql driver value to null string

func (*NullString) UnmarshalJSON

func (t *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON converts json string to null string

func (NullString) Value

func (ns NullString) Value() (driver.Value, error)

Value converts null string to sql driver value

type Page

type Page[T any] struct {
	Items      []T    `json:"items"`
	TotalItems uint64 `json:"totalItems"`
}

Page is the page response contract

type PageRequest

type PageRequest struct {
	Page  uint16
	Size  uint16
	Order []Sort
}

PageRequest is the contract of request page

func NewPageRequest

func NewPageRequest(page uint16, size uint16, order []Sort) *PageRequest

NewPageRequest returns a new page request pointer

func (*PageRequest) GetOrder

func (p *PageRequest) GetOrder() string

GetOrder returns string contains concated order list

type Sort

type Sort struct {
	Direction SortDirection
	Field     string
}

Sort is the contract to sort a field

func NewSort

func NewSort(direction SortDirection, field string) Sort

NewSort returns a new Sort

type SortDirection

type SortDirection string

SortDirection is the field sort direction

const (
	ASC  SortDirection = "ASC"
	DESC SortDirection = "DESC"
)

func (SortDirection) IsValid

func (sd SortDirection) IsValid() bool

IsValid checks if the SortDirection is valid. It returns true if the SortDirection is valid, otherwise false.

Jump to

Keyboard shortcuts

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