mongo

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INCLUDE_MISSSING = " INCLUDE MISSING"
	ASC              = " ASC"
	DESC             = " DESC"
)

Variables

This section is empty.

Functions

func ConvertMongoToCouchbase

func ConvertMongoToCouchbase(expression bson.D, fieldPath IndexFieldPath) (string, error)

ConvertMongoToCouchbase Convert MongoDB partial filter expression to Couchbase WHERE clause

func CreateIndexQuery

func CreateIndexQuery(bucket, scope, collection string, index Index, fieldPath IndexFieldPath) (string, error)

func GenerateArrayFilterExpression

func GenerateArrayFilterExpression(input string, isTypeFilter bool, condition string) string

func GenerateCouchbaseArrayIndex

func GenerateCouchbaseArrayIndex(input string) string

GenerateCouchbaseArrayIndex generates a Couchbase array index expression from a given input pattern like "schedule[].special_flights[].flight".

func GroupAndCombine

func GroupAndCombine(keys []Key, includeMissing bool) (string, error)

GroupAndCombine array fields are combined because only one array field can be indexed in a compound index

func NewIndexFieldAnalyzer

func NewIndexFieldAnalyzer() common.Analyzer[Index]

func NewMongo

func NewMongo(db repo.IRepo) common.ISource[Index, option.Options]

func ProcessField

func ProcessField(field string, value interface{}, fieldPath IndexFieldPath) (string, error)

ProcessField Process individual field conditions

Types

type Index

type Index struct {
	Name              string
	Keys              []Key
	PartialExpression bson.D
	Unique            bool
	Sparse            bool
	Error             error
}

type IndexFieldAnalyzer

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

func (*IndexFieldAnalyzer) AnalyzeData

func (a *IndexFieldAnalyzer) AnalyzeData(data map[string]interface{})

func (*IndexFieldAnalyzer) GetCouchbaseQuery

func (a *IndexFieldAnalyzer) GetCouchbaseQuery(bucket, scope, collection string) []common.Index

func (*IndexFieldAnalyzer) GetIndexFieldPath

func (a *IndexFieldAnalyzer) GetIndexFieldPath() IndexFieldPath

func (*IndexFieldAnalyzer) Init

func (a *IndexFieldAnalyzer) Init(indexes []Index, dk common.IDocumentKey)

type IndexFieldPath

type IndexFieldPath map[string]string

IndexFieldPath is used to have array representation for a particular path example: k1.n1k1.n2k1 is path for field n2k1 in a document. n1k1 is an array, and it is represented as k1.n1k1[].n2k1.

func (IndexFieldPath) Get

func (i IndexFieldPath) Get(key string) string

type Key

type Key struct {
	Field string
	Order int
}

type Mongo

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

func (*Mongo) GetIndexes

func (m *Mongo) GetIndexes(ctx context.Context) ([]Index, error)

func (*Mongo) Init

func (m *Mongo) Init(opts *option.Options) error

func (*Mongo) StreamData

func (m *Mongo) StreamData(ctx context.Context, mChan chan map[string]interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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