orderby

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(sw io.StringWriter, sorting []Sort) error

Write writes a ORDER BY clause to the given string writer. Add direction to the column name to change the direction.

Example:

Mysql:
	ORDER BY field1 DESC, field2 ASC, field3 ASC
Postgres:
	ORDER BY field1 DESC, field2 ASC, field3 ASC

Types

type Clause

type Clause struct {
	// contains filtered or unexported fields
}

Clause represents a ORDER BY clause.

func New

func New(sorting []Sort) *Clause

func (*Clause) Type

func (o *Clause) Type() clauses.ClauseType

func (*Clause) WriteTo

func (o *Clause) WriteTo(sw io.StringWriter) error

type Direction

type Direction int

Direction of the order.

const (
	ASC Direction = iota
	DESC
)

func (Direction) String

func (i Direction) String() string

type Sort

type Sort struct {
	// Column to order by.
	*expressions.Column
	// Direction of the order.
	Direction Direction
}

Column to order by.

func NewSort

func NewSort(column *expressions.Column, direction Direction) Sort

NewSort creates a new Sort.

func (Sort) WriteTo

func (s Sort) WriteTo(sw io.StringWriter) error

WriteTo writes a ORDER BY clause to the given string writer.

Jump to

Keyboard shortcuts

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