dbs

package
v0.0.0-...-cef23b5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBson

func GetBson(filters *Filters) bson.D

func InputToBson

func InputToBson(i Input, isUpdate bool) bson.D

Types

type Filter

type Filter struct {
	Operator string      `json:"operator,omitempty"`
	Value    interface{} `json:"value,omitempty"`
}

type Filters

type Filters struct {
	And map[string][]Filter `json:"and"`
	Or  map[string][]Filter `json:"or"`
}

func FiltersFromFlatMap

func FiltersFromFlatMap(flatMap map[string]interface{}, target interface{}) *Filters

FiltersFromFlatMap builds a *Filters from a map[string]interface{} whose structure mirrors the JSON form of Filters:

{
  "and": { "name": [{"operator":"like","value":"foo"}] },
  "or":  { "source": [{"operator":"equal","value":"bar"}] }
}

Keys inside "and"/"or" are json tag names; the function resolves each to its full dotted BSON path using the target struct. Unknown keys are kept as-is.

type Input

type Input = map[string]interface{}

type Operator

type Operator int
const (
	LIKE Operator = iota
	EXISTS
	IN
	GTE
	LTE
	LT
	GT
	EQUAL
	NOT
	ELEMMATCH
	OR
)

func StringToOperator

func StringToOperator(s string) Operator

func (Operator) String

func (m Operator) String() string

func (Operator) ToMongoOperator

func (m Operator) ToMongoOperator(k string, value interface{}) bson.M

func (Operator) ToValueOperator

func (m Operator) ToValueOperator(operator Operator, value interface{}, or bool) interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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