mango

package
v0.0.0-...-4b98c26 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const MaxString = string(unicode.MaxRune)

MaxString is the unicode character \uFFFF, useful as an upperbound for queryies

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	json.Marshaler
	ToMango() Map
}

A Filter is a filter on documents, to be passed as the selector of a couchdb.FindRequest In the future, we might add go-side validation but we will need to duplicate the couchdb UCA algorithm

func And

func And(filters ...Filter) Filter

And returns a filter combining several filters

func Between

func Between(field string, v1 interface{}, v2 interface{}) Filter

Between returns a filter that check if v1 <= field < v2

func Equal

func Equal(field string, value interface{}) Filter

Equal returns a filter that check if a field == value

func Exists

func Exists(field string) Filter

Exists returns a filter that check that the document has this field

func Gt

func Gt(field string, value interface{}) Filter

Gt returns a filter that check if a field > value

func Gte

func Gte(field string, value interface{}) Filter

Gte returns a filter that check if a field >= value

func Lt

func Lt(field string, value interface{}) Filter

Lt returns a filter that check if a field < value

func Lte

func Lte(field string, value interface{}) Filter

Lte returns a filter that check if a field <= value

func Nor

func Nor(filters ...Filter) Filter

Nor returns a filter combining several filters

func Not

func Not(filter Filter) Filter

Not returns a filter inversing another filter

func NotEqual

func NotEqual(field string, value interface{}) Filter

NotEqual returns a filter that check if a field != value

func Or

func Or(filters ...Filter) Filter

Or returns a filter combining several filters

func StartWith

func StartWith(field string, prefix string) Filter

StartWith returns a filter that check if field's string value start with prefix

type Index

type Index struct {
	Doctype string
	Request *IndexRequest
}

Index contains an index request on a specified domain.

func IndexOnFields

func IndexOnFields(doctype, name string, fields []string) *Index

IndexOnFields constructs a new Index it lets couchdb defaults for index & designdoc names.

type IndexFields

type IndexFields []string

An IndexFields is just a list of fields to be indexed.

func (IndexFields) MarshalJSON

func (def IndexFields) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface on IndexFields by wrapping it in a {"fields": ...}

type IndexRequest

type IndexRequest struct {
	Name  string      `json:"name,omitempty"`
	DDoc  string      `json:"ddoc,omitempty"`
	Index IndexFields `json:"index"`
}

IndexRequest is a request to be POSTED to create the index

type LogicOperator

type LogicOperator string

LogicOperator is an operator between two filters

type Map

type Map map[string]interface{}

Map is an alias for map[string]interface{}

func (Map) MarshalJSON

func (m Map) MarshalJSON() ([]byte, error)

MarshalJSON returns a byte json representation of the map

func (Map) ToMango

func (m Map) ToMango() Map

ToMango implements the Filter interface on Map it returns the map itself

type SortBy

type SortBy []SortByField

SortBy is a sorting rule to be used as the sort of a couchdb.FindRequest a list of (field, direction) combination.

func (SortBy) MarshalJSON

func (s SortBy) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller on SortBy it will returns a json array [field, direction]

type SortByField

type SortByField struct {
	Field     string
	Direction SortDirection
}

SortByField is a sorting rule to be used as the sort for a pair of (field, direction).

type SortDirection

type SortDirection string

SortDirection can be either ASC or DESC

const Asc SortDirection = "asc"

Asc is the ascending sorting order

const Desc SortDirection = "desc"

Desc is the descending sorting order

type ValueOperator

type ValueOperator string

ValueOperator is an operator between a field and a value

Jump to

Keyboard shortcuts

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