Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
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 ¶
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) Set ¶
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.