pgquery

package module
v0.0.0-...-d190453 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 7 Imported by: 0

README

gopg Query

license goversion

Writing queries made easier with a set of Postgres common condition ORM helpers for go-pg.

Installation

Use go get to retrieve the ORM helpers to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/junwen-k/pgquery

To update the ORM helpers use go get -u to retrieve the latest version of the ORM helpers.

go get -u github.com/junwen-k/pgquery

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTimeRange

type DateTimeRange struct {
	Gt  *time.Time `json:"after,omitempty"`
	Gte *time.Time `json:"from,omitempty"`
	Lt  *time.Time `json:"before,omitempty"`
	Lte *time.Time `json:"to,omitempty"`
	// contains filtered or unexported fields
}

DateTimeRange common datetime range filter.

func NewDateTimeRange

func NewDateTimeRange(column string, layouts ...string) *DateTimeRange

NewDateTimeRange initializes a new datetime range filter.

func (*DateTimeRange) After

func (f *DateTimeRange) After(value time.Time) *DateTimeRange

After set value for after (gt).

func (*DateTimeRange) AfterMarshalLayout

func (f *DateTimeRange) AfterMarshalLayout(layout string) *DateTimeRange

AfterMarshalLayout set marshal layout for after (gt).

func (*DateTimeRange) Appender

func (f *DateTimeRange) Appender() applyFn

Appender returns parameters for cond group appender.

func (*DateTimeRange) Before

func (f *DateTimeRange) Before(value time.Time) *DateTimeRange

Before set value for before (lt).

func (*DateTimeRange) BeforeMarshalLayout

func (f *DateTimeRange) BeforeMarshalLayout(layout string) *DateTimeRange

BeforeMarshalLayout set marshal layout for before (lt).

func (*DateTimeRange) Column

func (f *DateTimeRange) Column(column string) *DateTimeRange

Column sets the column for the datetime range filter.

func (*DateTimeRange) From

func (f *DateTimeRange) From(value time.Time) *DateTimeRange

From set value for from (gte).

func (*DateTimeRange) FromMarshalLayout

func (f *DateTimeRange) FromMarshalLayout(layout string) *DateTimeRange

FromMarshalLayout set marshal layout for from (gte).

func (*DateTimeRange) Layout

func (f *DateTimeRange) Layout(layouts ...string) *DateTimeRange

Layout sets the parsing layout(s) for the datetime range filter.

func (*DateTimeRange) MarshalJSON

func (f *DateTimeRange) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*DateTimeRange) To

func (f *DateTimeRange) To(value time.Time) *DateTimeRange

To set value for to (lte).

func (*DateTimeRange) ToMarshalLayout

func (f *DateTimeRange) ToMarshalLayout(layout string) *DateTimeRange

ToMarshalLayout set marshal layout for to (lte).

func (*DateTimeRange) UnmarshalJSON

func (f *DateTimeRange) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

type Exists

type Exists struct {
	Value *bool `json:"value,omitempty"`
	// contains filtered or unexported fields
}

Exists exists common filter.

func NewExists

func NewExists(column string) *Exists

NewExists initializes a new exists filter.

func (*Exists) Appender

func (f *Exists) Appender() (string, interface{}, interface{})

Appender returns parameters for cond appender.

func (*Exists) Column

func (f *Exists) Column(column string) *Exists

Column set the column(s) for the exists filter.

func (*Exists) Exists

func (f *Exists) Exists(value bool) *Exists

Exists set value.

func (*Exists) MarshalJSON

func (f *Exists) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*Exists) ShouldExists

func (f *Exists) ShouldExists() *Exists

ShouldExists set value to true.

func (*Exists) ShouldNotExists

func (f *Exists) ShouldNotExists() *Exists

ShouldNotExists set value to false.

func (*Exists) UnmarshalJSON

func (f *Exists) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

type KeywordSearch

type KeywordSearch struct {
	Value *string `json:"value,omitempty"`
	// contains filtered or unexported fields
}

KeywordSearch keyword search common filter.

func NewKeywordSearch

func NewKeywordSearch(column string) *KeywordSearch

NewKeywordSearch initializes a new keyword search filter.

func (*KeywordSearch) Appender

func (f *KeywordSearch) Appender() (string, interface{}, interface{}, interface{})

Appender returns parameters for cond appender.

func (*KeywordSearch) CaseInsensitive

func (f *KeywordSearch) CaseInsensitive() *KeywordSearch

CaseInsensitive set keyword case insensitive for the keyword search filter.

func (*KeywordSearch) Column

func (f *KeywordSearch) Column(column string) *KeywordSearch

Column set the column for the keyword search filter. Suffix column with ",array" to use array search.

func (*KeywordSearch) Keyword

func (f *KeywordSearch) Keyword(keyword string) *KeywordSearch

Keyword set value.

func (*KeywordSearch) MarshalJSON

func (f *KeywordSearch) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*KeywordSearch) MatchAll

func (f *KeywordSearch) MatchAll() *KeywordSearch

MatchAll set keyword match all for the keyword search filter.

func (*KeywordSearch) MatchEnd

func (f *KeywordSearch) MatchEnd() *KeywordSearch

MatchEnd set keyword match end for the keyword search filter.

func (*KeywordSearch) MatchStart

func (f *KeywordSearch) MatchStart() *KeywordSearch

MatchStart set keyword match start for the keyword search filter.

func (*KeywordSearch) UnmarshalJSON

func (f *KeywordSearch) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

type Match

type Match struct {
	Values []interface{} `json:"values,omitempty"`
	// contains filtered or unexported fields
}

Match match common filter.

func NewMatch

func NewMatch(column string) *Match

NewMatch initializes a new match filter.

func (*Match) Appender

func (f *Match) Appender() (string, interface{}, interface{})

Appender returns parameters for cond appender.

func (*Match) Column

func (f *Match) Column(column string) *Match

Column sets the column for the match filter.

func (*Match) MarshalJSON

func (f *Match) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*Match) Matches

func (f *Match) Matches(values ...interface{}) *Match

Matches set value(s).

func (*Match) UnmarshalJSON

func (f *Match) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

type OffsetPagination

type OffsetPagination struct {
	Page  int  `json:"page,omitempty"`
	Limit *int `json:"limit,omitempty"`
}

OffsetPagination pagination common filter. Offset pagination is skipped when no limit is provided.

func NewOffsetPagination

func NewOffsetPagination() *OffsetPagination

NewOffsetPagination initializes a new pagination filter.

func (*OffsetPagination) Appender

func (f *OffsetPagination) Appender() applyFn

Appender returns parameters for cond group appender.

func (*OffsetPagination) Offset

func (f *OffsetPagination) Offset(page int, limit int) *OffsetPagination

Offset sets offset value for the pagination filter.

type Order

type Order struct {
	Direction *OrderDirection `json:"direction,omitempty"`
	// contains filtered or unexported fields
}

Order order common sorter.

func NewOrder

func NewOrder(column string) *Order

NewOrder initializes a new order sorter.

func NewOrderAsc

func NewOrderAsc(column string) *Order

NewOrderAsc initializes a new ascending order sorter.

func NewOrderDesc

func NewOrderDesc(column string) *Order

NewOrderDesc initializes a new order sorter.

func (*Order) Appender

func (s *Order) Appender() (string, interface{}, interface{})

Appender returns parameters for cond appender.

func (*Order) Asc

func (s *Order) Asc() *Order

Asc sets the direction to ascending order.

func (*Order) Column

func (s *Order) Column(column string) *Order

Column sets the column for the order sorter.

func (*Order) Desc

func (s *Order) Desc() *Order

Desc sets the direction to descending order.

func (*Order) MarshalJSON

func (s *Order) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*Order) UnmarshalJSON

func (s *Order) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

type OrderDirection

type OrderDirection int

OrderDirection order direction enum type.

const (
	// OrderDirectionAsc order direction ascending enum.
	OrderDirectionAsc OrderDirection = iota

	// OrderDirectionDesc order direction descending enum.
	OrderDirectionDesc
)

func (OrderDirection) String

func (d OrderDirection) String() string

String returns the string presentation for the order direction.

type Range

type Range struct {
	Gt  *int `json:"gt,omitempty"`
	Gte *int `json:"gte,omitempty"`
	Lt  *int `json:"lt,omitempty"`
	Lte *int `json:"lte,omitempty"`
	// contains filtered or unexported fields
}

Range range common filter.

func NewRange

func NewRange(column string) *Range

NewRange initializes a new range filter.

func (*Range) Appender

func (f *Range) Appender() applyFn

Appender returns parameters for cond group appender.

func (*Range) Column

func (f *Range) Column(column string) *Range

Column set the column for the range filter.

func (*Range) GreaterThan

func (f *Range) GreaterThan(value int) *Range

GreaterThan set value for greater than (gt).

func (*Range) GreaterThanEqual

func (f *Range) GreaterThanEqual(value int) *Range

GreaterThanEqual set value for greater than (gte).

func (*Range) LessThan

func (f *Range) LessThan(value int) *Range

LessThan set value for less than (lt).

func (*Range) LessThanEqual

func (f *Range) LessThanEqual(value int) *Range

LessThanEqual set value for less than equal (lte).

type RelativeDateTimeRange

type RelativeDateTimeRange struct {
	Ago      *RelativeDateTimeRangeUnitOption `json:"ago,omitempty"`
	Upcoming *RelativeDateTimeRangeUnitOption `json:"upcoming,omitempty"`
	At       *time.Time                       `json:"at,omitempty"`
	// contains filtered or unexported fields
}

RelativeDateTimeRange relative datetime range common filter.

func NewRelativeDateTimeRange

func NewRelativeDateTimeRange(column string, layouts ...string) *RelativeDateTimeRange

NewRelativeDateTimeRange initializes a new relative datetime filter.

func (*RelativeDateTimeRange) AgoCentury

func (f *RelativeDateTimeRange) AgoCentury(value int) *RelativeDateTimeRange

AgoCentury set century for ago.

func (*RelativeDateTimeRange) AgoDay

AgoDay set day for ago.

func (*RelativeDateTimeRange) AgoDecade

func (f *RelativeDateTimeRange) AgoDecade(value int) *RelativeDateTimeRange

AgoDecade set decade for ago.

func (*RelativeDateTimeRange) AgoHour

func (f *RelativeDateTimeRange) AgoHour(value int) *RelativeDateTimeRange

AgoHour set hour for ago.

func (*RelativeDateTimeRange) AgoMicrosecond

func (f *RelativeDateTimeRange) AgoMicrosecond(value int) *RelativeDateTimeRange

AgoMicrosecond set microsecond for ago.

func (*RelativeDateTimeRange) AgoMillennium

func (f *RelativeDateTimeRange) AgoMillennium(value int) *RelativeDateTimeRange

AgoMillennium set millennium for ago.

func (*RelativeDateTimeRange) AgoMillisecond

func (f *RelativeDateTimeRange) AgoMillisecond(value int) *RelativeDateTimeRange

AgoMillisecond set millisecond for ago.

func (*RelativeDateTimeRange) AgoMinute

func (f *RelativeDateTimeRange) AgoMinute(value int) *RelativeDateTimeRange

AgoMinute set minute for ago.

func (*RelativeDateTimeRange) AgoMonth

func (f *RelativeDateTimeRange) AgoMonth(value int) *RelativeDateTimeRange

AgoMonth set month for ago.

func (*RelativeDateTimeRange) AgoSecond

func (f *RelativeDateTimeRange) AgoSecond(value int) *RelativeDateTimeRange

AgoSecond set second for ago.

func (*RelativeDateTimeRange) AgoWeek

func (f *RelativeDateTimeRange) AgoWeek(value int) *RelativeDateTimeRange

AgoWeek set week for ago.

func (*RelativeDateTimeRange) AgoYear

func (f *RelativeDateTimeRange) AgoYear(value int) *RelativeDateTimeRange

AgoYear set year for ago.

func (*RelativeDateTimeRange) Appender

func (f *RelativeDateTimeRange) Appender() applyFn

Appender returns parameters for cond group appender.

func (*RelativeDateTimeRange) AsAt

AsAt set value.

func (*RelativeDateTimeRange) Column

Column sets the column for the relative datetime filter.

func (*RelativeDateTimeRange) Layout

func (f *RelativeDateTimeRange) Layout(layouts ...string) *RelativeDateTimeRange

Layout sets the parsing layout(s) for the relative datetime filter.

func (*RelativeDateTimeRange) MarshalJSON

func (f *RelativeDateTimeRange) MarshalJSON() ([]byte, error)

MarshalJSON custom JSON marshaler.

func (*RelativeDateTimeRange) MarshalLayout

func (f *RelativeDateTimeRange) MarshalLayout(layout string) *RelativeDateTimeRange

MarshalLayout set marshal layout.

func (*RelativeDateTimeRange) UnmarshalJSON

func (f *RelativeDateTimeRange) UnmarshalJSON(b []byte) error

UnmarshalJSON custom JSON unmarshaler.

func (*RelativeDateTimeRange) UpcomingCentury

func (f *RelativeDateTimeRange) UpcomingCentury(value int) *RelativeDateTimeRange

UpcomingCentury set century for upcoming.

func (*RelativeDateTimeRange) UpcomingDay

func (f *RelativeDateTimeRange) UpcomingDay(value int) *RelativeDateTimeRange

UpcomingDay set day for upcoming.

func (*RelativeDateTimeRange) UpcomingDecade

func (f *RelativeDateTimeRange) UpcomingDecade(value int) *RelativeDateTimeRange

UpcomingDecade set decade for upcoming.

func (*RelativeDateTimeRange) UpcomingHour

func (f *RelativeDateTimeRange) UpcomingHour(value int) *RelativeDateTimeRange

UpcomingHour set hour for upcoming.

func (*RelativeDateTimeRange) UpcomingMicrosecond

func (f *RelativeDateTimeRange) UpcomingMicrosecond(value int) *RelativeDateTimeRange

UpcomingMicrosecond set microsecond for upcoming.

func (*RelativeDateTimeRange) UpcomingMillennium

func (f *RelativeDateTimeRange) UpcomingMillennium(value int) *RelativeDateTimeRange

UpcomingMillennium set millennium for upcoming.

func (*RelativeDateTimeRange) UpcomingMillisecond

func (f *RelativeDateTimeRange) UpcomingMillisecond(value int) *RelativeDateTimeRange

UpcomingMillisecond set millisecond for upcoming.

func (*RelativeDateTimeRange) UpcomingMinute

func (f *RelativeDateTimeRange) UpcomingMinute(value int) *RelativeDateTimeRange

UpcomingMinute set minute for upcoming.

func (*RelativeDateTimeRange) UpcomingMonth

func (f *RelativeDateTimeRange) UpcomingMonth(value int) *RelativeDateTimeRange

UpcomingMonth set month for upcoming.

func (*RelativeDateTimeRange) UpcomingSecond

func (f *RelativeDateTimeRange) UpcomingSecond(value int) *RelativeDateTimeRange

UpcomingSecond set second for upcoming.

func (*RelativeDateTimeRange) UpcomingWeek

func (f *RelativeDateTimeRange) UpcomingWeek(value int) *RelativeDateTimeRange

UpcomingWeek set week for upcoming.

func (*RelativeDateTimeRange) UpcomingYear

func (f *RelativeDateTimeRange) UpcomingYear(value int) *RelativeDateTimeRange

UpcomingYear set year for upcoming.

type RelativeDateTimeRangeUnitOption

type RelativeDateTimeRangeUnitOption struct {
	Century     *int `json:"century,omitempty"`
	Day         *int `json:"day,omitempty"`
	Decade      *int `json:"decade,omitempty"`
	Hour        *int `json:"hour,omitempty"`
	Microsecond *int `json:"microsecond,omitempty"`
	Millennium  *int `json:"millennium,omitempty"`
	Millisecond *int `json:"millisecond,omitempty"`
	Minute      *int `json:"minute,omitempty"`
	Month       *int `json:"month,omitempty"`
	Second      *int `json:"second,omitempty"`
	Week        *int `json:"week,omitempty"`
	Year        *int `json:"year,omitempty"`
}

RelativeDateTimeRangeUnitOption relative datetime range unit option.

Jump to

Keyboard shortcuts

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