index

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Copyright (c) 2023 the go-mongr8 Authors and Contributors [@see Authors file]

Licensed under the MIT License (https://opensource.org/licenses/MIT)

Copyright (c) 2023 the go-mongr8 Authors and Contributors [@see Authors file]

Licensed under the MIT License (https://opensource.org/licenses/MIT)

Index

Constants

View Source
const (
	// Index Types
	TypeSingleField       IndexType = "TypeSingleField"
	TypeCompound          IndexType = "TypeCompound"
	TypeText              IndexType = "TypeText"
	TypeGeopatial2dsphere IndexType = "TypeGeopatial2dsphere"
	TypeHashed            IndexType = "TypeHashedIndex"
	TypeRaw               IndexType = "TypeRaw"
	// Index Options
	OptionSparse           = "sparse"
	OptionBackground       = "background"
	OptionUnique           = "unique"
	OptionHidden           = "hidden"
	OptionPartialFilterExp = "partialFilterExpression"
	OptionTTL              = "expireAfterSeconds"
	OptionCollation        = "collation"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexField

type IndexField struct {
	Key   string
	Value interface{}
}

func Field

func Field(name string, value ...interface{}) IndexField

func NewIndexField

func NewIndexField(key string, value interface{}) IndexField

func (IndexField) NestedField

func (f IndexField) NestedField(name string) IndexField

type IndexSpec

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

func CompoundIndex

func CompoundIndex(fields ...IndexField) *IndexSpec

func Geospatial2dsphereIndex

func Geospatial2dsphereIndex(field IndexField) *IndexSpec

func HashedIndex

func HashedIndex(field IndexField) *IndexSpec

func RawIndex

func RawIndex(fields map[string]interface{}, rules *map[string]interface{}) *IndexSpec

func SingleFieldIndex

func SingleFieldIndex(field IndexField) *IndexSpec

func TextIndex

func TextIndex(field IndexField) *IndexSpec

func (*IndexSpec) AsBackground

func (b *IndexSpec) AsBackground() *IndexSpec

Set `background` option. Creates the index in the background so it doesn't block reads/writes.

func (*IndexSpec) AsHidden

func (b *IndexSpec) AsHidden() *IndexSpec

Set `hidden` option. Creates an index that is hidden from the query optimizer.

func (*IndexSpec) AsSparse

func (b *IndexSpec) AsSparse() *IndexSpec

Set `sparse` option Only indexes documents that have particular field

func (*IndexSpec) AsUnique

func (b *IndexSpec) AsUnique() *IndexSpec

Set `unique` option. Adds uniqueness constraint to the field.

func (*IndexSpec) InitRules

func (b *IndexSpec) InitRules()

func (*IndexSpec) MustNotRaw

func (b *IndexSpec) MustNotRaw()

Panic if index is raw type

func (*IndexSpec) SetCollation

func (b *IndexSpec) SetCollation(collation map[string]interface{}) *IndexSpec

Set `collation` option Creates index with custom collation

func (*IndexSpec) SetCustomIndexName

func (b *IndexSpec) SetCustomIndexName(name string) *IndexSpec

func (*IndexSpec) SetPartialExpression

func (b *IndexSpec) SetPartialExpression(partialExp map[string]interface{}) *IndexSpec

Set `partialFilterExpression` option. Indexes with particular filters.

func (*IndexSpec) SetRules

func (b *IndexSpec) SetRules(rules map[string]interface{})

func (*IndexSpec) SetTTL

func (b *IndexSpec) SetTTL(expireAfterSeconds int32) *IndexSpec

Set `expireAfterSeconds` option Adds TTL index to a timestamp field

func (*IndexSpec) Spec

func (b *IndexSpec) Spec() *Spec

type IndexType

type IndexType string

type Spec

type Spec struct {
	Type   IndexType
	Fields []IndexField
	Rules  *map[string]interface{}
	Name   *string
}

func (*Spec) GetKey

func (s *Spec) GetKey() string

this is used for compare two index whether they both have the exact same structure

func (*Spec) GetName

func (s *Spec) GetName() string

func (*Spec) HasRule

func (b *Spec) HasRule(option string) bool

Check whether an option is set

Jump to

Keyboard shortcuts

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