index

package
v0.0.0-...-ba7cdbd Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2014 License: MPL-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ASC is used when creating indexes, to specify the ordering
	// of the field. See the documentation on DESC for further information.
	ASC = iota + 1
	// DESC is used when creating indexes to specify the ordering of the field. e.g.
	//
	//	index.New("A", "B", "C").Set(index.DESC, "B")
	//
	// will create an index where A and C are sorted in the default order
	// (usually ascending) while B is sorted in descending order.
	//
	// To specify the sorting for multiple fields, just use multiple values:
	//
	//	index.New("A", "B", "C").Set(index.DESC, "A", "B")
	DESC
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// They fields indexed by this index, in order. For creating
	// indexes on nested structures, separate the names with a
	// dot. e.g. given the types:
	//    type Foo struct {
	//	    A int64
	//	    B int64
	//    }
	//    type Bar struct {
	//        Foo
	//    }
	// To create a index in Bar over A and B, you'd do:
	//    New("Foo.A", "Foo.B")
	Fields []string
	// Wheter the index should be unique.
	Unique bool
	// contains filtered or unexported fields
}

func Indexes

func Indexes(indexes ...*Index) []*Index

Indexes takes a variable number of indexes and returns them as a slice. It's intended as a convenience function for declaring model options.

func New

func New(fields ...string) *Index

New returns an index for the given fields. The names should be qualified Go names (e.g. Id or Foo.Id, not id or foo_id).

func NewUnique

func NewUnique(fields ...string) *Index

NewUnique returns an unique index for the given fields. The names should be qualified Go names (e.g. Id or Foo.Id, not id or foo_id).

func (*Index) Get

func (i *Index) Get(opt int) interface{}

Get returns the value for the given option.

func (*Index) Set

func (i *Index) Set(opt int, values ...interface{}) *Index

Set sets a driver dependent option for the given index. The builtin drivers all use constants <= 10000, so if you're writing an ORM driver, use constants higher than that value. For conveniency, the options for the builtin drivers are defined as contants in this package. The same index is returned, to allow chaining calls.

Jump to

Keyboard shortcuts

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