domain

package
v0.0.0-...-caa70b2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringifyOrders

func StringifyOrders(s Sort) []string

StringifyOrders travers sort orders into a slice of strings in the following of "prop1 ASC, prop2 DESC".

Types

type Direction

type Direction string

Direction can be ASC, DESC, ASC_NULLS_FIRST, DESC_NULLS_FIRST, ASC_NULLS_LAST or DESC_NULLS_LAST.

const (
	ASC              Direction = "ASC"
	DESC             Direction = "DESC"
	ASC_NULLS_FIRST  Direction = "ASC NULLS FIRST"
	DESC_NULLS_FIRST Direction = "DESC NULLS FIRST"
	ASC_NULLS_LAST   Direction = "ASC NULLS LAST"
	DESC_NULLS_LAST  Direction = "DESC NULLS LAST"
)

type Entity

type Entity struct {
	ID        uuid.UUID `bun:",pk,autoincrement"`
	CreatedAt time.Time `bun:"created_at,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:"updated_at,notnull,default:current_timestamp"`
}

Entity represents base for every persistent entity like User.

type Order

type Order struct {
	Property  string
	Direction Direction
}

Order represent single sort instruction.

func NewOrder

func NewOrder(opts ...OrderOption) *Order

NewOrder creates new Order object.

type OrderOption

type OrderOption func(*Order)

OrderOption function is used for creating new Order object.

func WithDirection

func WithDirection(d Direction) OrderOption

func WithProperty

func WithProperty(p string) OrderOption

type Page

type Page[T any] struct {
	TotalPages    int
	TotalElements int
	Elements      []T
}

Page is generic struct that represents response made by page request.

type Pageable

type Pageable struct {
	Size   int
	Offset int
	Sort   Sort
}

Pageable represents the pagination request parameters.

type Sort

type Sort struct {
	Orders []*Order
}

Sort represents sorting options for pagination.

func NewSort

func NewSort(order ...*Order) Sort

NewSort creates new sort object from Orders.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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