mongo

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 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 NavigatePath(path string, data map[string]interface{}) (string, bool)

NavigatePath initiates the recursive path check.

func NewMongo

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

func ProcessField

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

ProcessField Process individual field conditions

Types

type Analyzer

type Analyzer interface {
	Init(index []Index, documentKey common.ICBDocumentKey)
	AnalyzeData(data map[string]interface{})
	GetCouchbaseQuery(bucket, scope, collection string) []common.Index
}

func NewIndexFieldAnalyzer

func NewIndexFieldAnalyzer() Analyzer

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) Init

func (a *IndexFieldAnalyzer) Init(indexes []Index, documentKey common.ICBDocumentKey)

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 {
	CopyIndexes bool
	// contains filtered or unexported fields
}

func (*Mongo) GetCouchbaseIndexesQuery

func (m *Mongo) GetCouchbaseIndexesQuery(bucket string, scope string, collection string) ([]common.Index, error)

func (*Mongo) GetIndexes

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

func (*Mongo) Init

func (m *Mongo) Init(opts *option.Options, documentKey common.ICBDocumentKey) 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