bucket

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

README

Bucket

Build Status Go Report Card Documentation

Simply Couchbase framework.

Project specifically focus on the one bucket as database approach and makes it easier to manage complex data sets. It tries to get rid of the embedded jsons per document and separate them into different documents behind the scenes.

Features:

  • Automatic index generator with indexable tags.
  • Simple usage through the handler.
  • Following best practices of Couchbase usage behind the scenes, which doesn't affect the user of the library.

Documentation

Index

Constants

View Source
const (
	FacetDate = iota
	FacetNumeric
	FacetTerm
)

Variables

View Source
var (
	ErrDocumentTypeAlredyExists = errors.New("document type alredy exists")
	ErrDocumentTypeDoesntExists = errors.New("document type doesn't exist")

	ErrEmptyField  = errors.New("field must be filled")
	ErrEmptyIndex  = errors.New("index must be filled")
	ErrEmptyType   = errors.New("source type must set")
	ErrEmptySource = errors.New("source name must set")

	ErrConjunctionAndDisjunktionIsNil = errors.New("conjunction and disjunction are nil")

	ErrEndAsTimeZero = errors.New("endAsTime is zero instant")

	ErrFirstParameterNotStruct = errors.New("first parameter is not a struct")
	ErrInputStructPointer      = errors.New("input struct must be pointer")
)

Functions

This section is empty.

Types

type CompoundQueries

type CompoundQueries struct {
	Conjunction []SearchQuery `json:"conjuncts,omitempty"`
	Disjunction []SearchQuery `json:"disjuncts,omitempty"`

	Limit  int `json:"-"`
	Offset int `json:"-"`
}

func (*CompoundQueries) Setup

func (c *CompoundQueries) Setup() error

type Configuration

type Configuration struct {
	Username         string `json:"username"`
	Password         string `json:"password"`
	BucketName       string `json:"bucket_name"`
	BucketPassword   string `json:"bucket_password"`
	ConnectionString string `json:"connection_string"`
	Separator        string `json:"separator"`
}

type FacetDef

type FacetDef struct {
	Name  string
	Type  int
	Field string
	Size  int
}

type Handler

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

func New

func New(c *Configuration) (*Handler, error)

func (*Handler) CompoundSearch

func (h *Handler) CompoundSearch(ctx context.Context, index string, q *CompoundQueries) ([]gocb.SearchResultHit, error)

func (*Handler) CompoundSearchWithFacets

func (h *Handler) CompoundSearchWithFacets(ctx context.Context, index string, q *CompoundQueries, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)

func (*Handler) CreateFullTextSearchIndex

func (h *Handler) CreateFullTextSearchIndex(ctx context.Context, def *IndexDefinition) error

func (*Handler) DeleteFullTextSearchIndex

func (h *Handler) DeleteFullTextSearchIndex(ctx context.Context, indexName string) error

func (*Handler) Get

func (h *Handler) Get(ctx context.Context, typ, id string, ptr interface{}) error

func (*Handler) GetAndTouch

func (h *Handler) GetAndTouch(ctx context.Context, typ, id string, ptr interface{}, ttl int) error

func (*Handler) GetManager

func (h *Handler) GetManager(ctx context.Context) *gocb.BucketManager

func (*Handler) Index

func (h *Handler) Index(ctx context.Context, v interface{}) error

func (*Handler) Insert

func (h *Handler) Insert(ctx context.Context, typ, id string, q interface{}) (string, error)

func (*Handler) InspectFullTextSearchIndex

func (h *Handler) InspectFullTextSearchIndex(ctx context.Context, indexName string) (bool, *IndexDefinition, error)

func (*Handler) Ping

func (h *Handler) Ping(ctx context.Context, services []gocb.ServiceType) (*gocb.PingReport, error)

func (*Handler) RangeSearch

func (h *Handler) RangeSearch(ctx context.Context, index string, q *RangeQuery) ([]gocb.SearchResultHit, error)

func (*Handler) RangeSearchWithFacets

func (h *Handler) RangeSearchWithFacets(ctx context.Context, index string, q *RangeQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)

func (*Handler) Remove

func (h *Handler) Remove(ctx context.Context, typ, id string, ptr interface{}) error

func (*Handler) SetDocumentType

func (h *Handler) SetDocumentType(ctx context.Context, name, prefix string) error

func (*Handler) SimpleSearch

func (h *Handler) SimpleSearch(ctx context.Context, index string, q *SearchQuery) ([]gocb.SearchResultHit, error)

func (*Handler) SimpleSearchWithFacets

func (h *Handler) SimpleSearchWithFacets(ctx context.Context, index string, q *SearchQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)

func (*Handler) Touch

func (h *Handler) Touch(ctx context.Context, typ, id string, ptr interface{}, ttl int) error

func (*Handler) Upsert

func (h *Handler) Upsert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (string, error)

func (*Handler) ValidateState

func (h *Handler) ValidateState() (bool, error)

type IndexDefaultMapping

type IndexDefaultMapping struct {
	Dynamic bool `json:"dynamic"`
	Enabled bool `json:"enabled"`
}

type IndexDefinition

type IndexDefinition struct {
	Type       string          `json:"type"`
	Name       string          `json:"name"`
	SourceType string          `json:"sourceType"`
	SourceName string          `json:"sourceName"`
	PlanParams IndexPlanParams `json:"planParams"`
	Params     IndexParams     `json:"params"`
}

func DefaultFullTextSearchIndexDefinition

func DefaultFullTextSearchIndexDefinition(meta IndexMeta) (*IndexDefinition, error)

type IndexDefs

type IndexDefs struct {
	UUID      string                     `json:"uuid"`
	IndexDefs map[string]IndexDefinition `json:"indexDefs"`
}

type IndexDocConfig

type IndexDocConfig struct {
	DocIDPrefixDelimiter string `json:"docid_prefix_delim"`
	DocIDRegexp          string `json:"docid_regexp"`
	Mode                 string `json:"mode"`
	TypeField            string `json:"type_field"`
}

type IndexMapping

type IndexMapping struct {
	DefaultAnalyzer       string              `json:"default_analyzer"`
	DefaultDatetimeParser string              `json:"default_datetime_parser"`
	DefaultField          string              `json:"default_field"`
	DefaultMapping        IndexDefaultMapping `json:"default_mapping"`
	DefaultType           string              `json:"default_type"`
	DocvaluesDynamic      bool                `json:"docvalues_dynamic"`
	IndexDynamic          bool                `json:"index_dynamic"`
	StoreDynamic          bool                `json:"store_dynamic"`
	TypeField             string              `json:"type_field"`
}

type IndexMeta

type IndexMeta struct {
	Name                 string
	SourceType           string
	SourceName           string
	DocIDPrefixDelimiter string
	DocIDRegexp          string
	TypeField            string
}

type IndexParams

type IndexParams struct {
	DocConfig IndexDocConfig `json:"doc_config"`
	Mapping   IndexMapping   `json:"mapping"`
	Store     IndexStore     `json:"store"`
}

type IndexPlanParams

type IndexPlanParams struct {
	MaxPartitionsPerPIndex int64 `json:"maxPartitionsPerPIndex"`
}

type IndexStore

type IndexStore struct {
	IndexType   string `json:"indexType"`
	KVStoreName string `json:"kvStoreName"`
}

type RangeQuery

type RangeQuery struct {
	StartAsTime time.Time `json:"-"`
	EndAsTime   time.Time `json:"-"`
	Start       string    `json:"start,omitempty"`
	End         string    `json:"end,omitempty"`

	Min int64 `json:"min,omitempty"`
	Max int64 `json:"max,omitempty"`

	InclusiveStart bool `json:"inclusive_start,omitempty"`
	InclusiveEnd   bool `json:"inclusive_end,omitempty"`
	InclusiveMin   bool `json:"inclusive_min,omitempty"`
	InclusiveMax   bool `json:"inclusive_max,omitempty"`

	Field string `json:"field,omitempty"`

	Limit  int `json:"-"`
	Offset int `json:"-"`
}

func (*RangeQuery) Setup

func (d *RangeQuery) Setup() error

type SearchQuery

type SearchQuery struct {
	Query       string `json:"query,omitempty"`
	Match       string `json:"match,omitempty"`
	MatchPhrase string `json:"match_phrase,omitempty"`
	Term        string `json:"term,omitempty"`
	Prefix      string `json:"prefix,omitempty"`
	Regexp      string `json:"regexp,omitempty"`
	Wildcard    string `json:"wildcard,omitempty"`

	Field        string `json:"field,omitempty"`
	Analyzer     string `json:"analyzer,omitempty"`
	Fuzziness    int64  `json:"fuzziness,omitempty"`
	PrefixLength int64  `json:"prefix_length,omitempty"`

	Limit  int `json:"-"`
	Offset int `json:"-"`
}

func (*SearchQuery) Setup

func (s *SearchQuery) Setup() error

Jump to

Keyboard shortcuts

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