expressions

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Include a certain field
	Include = true
	// Exclude a certain field
	Exclude = false
	// MetaTextScore returns the score of the match for a text filtered query
	MetaTextScore = &bson.M{
		"$meta": "textScore",
	}
)

Functions

func AND

func AND(expressions ...interface{}) interface{}

AND is true if all expressions evaluate as true

func ArrayConcat

func ArrayConcat(arrays ...interface{}) interface{}

ArrayConcat takes an array of expressions that evaluate to array and return the joined array of these

func ArrayContains

func ArrayContains(arrayToBeSearched interface{}, searchExpression interface{}) interface{}

ArrayContains returns true if array contains the evaluated value of expression

func ArrayElementAt

func ArrayElementAt(array interface{}, i interface{}) interface{}

ArrayElementAt gets the element at a specfifed location in the array

func ArrayFilter

func ArrayFilter(array interface{}, variableName interface{}, condition interface{}) interface{}

ArrayFilter filters an array by checking if the condition matches for an element. variableName is the variable to use for for the element

func ArrayIndex

func ArrayIndex(arrayToBeSearched interface{}, searchExpression interface{}, start interface{}, end interface{}) interface{}

ArrayIndex returns the index of the first match of search on the array between start and end indexes (zero based). Returns -1 if search can not be satisfied

func ArrayIsAllTrue

func ArrayIsAllTrue(array interface{}) interface{}

ArrayIsAllTrue returns true if all elements in the array are not 'false, null, 0 or undefined'

func ArrayIsAnyTrue

func ArrayIsAnyTrue(expressions ...interface{}) interface{}

ArrayIsAnyTrue returns true if any element in the array is not 'false, null, 0 or undefined'

func ArrayMap

func ArrayMap(input interface{}, variableName interface{}, expression interface{}) interface{}

ArrayMap loops over input and calls expression with the array element as a variable with the variableName name and appends its output to a new array

func ArrayMax

func ArrayMax(expression interface{}) interface{}

ArrayMax takes an expression, evaluates it to an array and returns the largest of the values in the array or ArrayMax takes an array and returns the largest of the values in the array

func ArrayMerge

func ArrayMerge(expression interface{}) interface{}

ArrayMerge takes an expression, evaluates it to an array and returns the merged object of the elements in the array or ArrayMerge takes an array and returns the merged object of the elements in the array

func ArrayMin

func ArrayMin(expression interface{}) interface{}

ArrayMin takes an expression, evaluates it to an array and returns the smallest of the values in the array or ArrayMin takes an array and returns the smallest of the values in the array

func ArrayReduce

func ArrayReduce(array interface{}, startValue interface{}, reducer interface{}) interface{}

ArrayReduce returns a single value computed from the array with the reducer expression

func ArrayReverse

func ArrayReverse(array interface{}) interface{}

ArrayReverse reverses an array

func ArraySize

func ArraySize(array interface{}) interface{}

ArraySize returns the length of an array

func ArraySlice

func ArraySlice(array interface{}, n interface{}, startPosition interface{}) interface{}

ArraySlice returns n items from the array starting at the start position

func ArrayToObject

func ArrayToObject(array interface{}) interface{}

ArrayToObject takes an array of kv arrays or objects and maps them to one object

func ArrayZip

func ArrayZip(useLongest bool, def interface{}, arrays ...interface{}) interface{}

ArrayZip returns an array of arrays with one item from each array in the sub arrays

func Compare

func Compare(first interface{}, second interface{}) interface{}

Compare takes two values and compares them -1 if the first value is less than the second 1 if the first value is greater than the second 0 if the two values are equivalent

func Condition

func Condition(expression interface{}, trueCase interface{}, falseCase interface{}) interface{}

Condition takes an boolean expression and returns an expression depending on the value of the boolean expression

func Convert

func Convert(input interface{}, typ types.Type, onError interface{}, onNull interface{}) interface{}

Convert one type too another. onError and onNull are optional and thus may be nil

func DateDayOfMonth

func DateDayOfMonth(date interface{}, timezone interface{}) interface{}

DateDayOfMonth takes a date and returns the day of the month

func DateDayOfWeek

func DateDayOfWeek(date interface{}, timezone interface{}) interface{}

DateDayOfWeek takes a date and returns the day of the week

func DateDayOfYear

func DateDayOfYear(date interface{}, timezone interface{}) interface{}

DateDayOfYear takes a date and returns the day of the year

func DateFromParts

func DateFromParts(year interface{}, month interface{}, day interface{}, hour interface{}, minute interface{}, second interface{}, millisecond interface{}, timezone interface{}) interface{}

DateFromParts makes a date from the parts of that date

func DateFromPartsISO

func DateFromPartsISO(weekYear interface{}, week interface{}, dayOfWeek interface{}, hour interface{}, minute interface{}, second interface{}, millisecond interface{}, timezone interface{}) interface{}

DateFromPartsISO makes an ISO date from the parts of that date

func DateFromString

func DateFromString(dateString interface{}, format interface{}, timezone interface{}, onError interface{}, onNull interface{}) interface{}

DateFromString makes a date from a format and a string

func DateHour

func DateHour(date interface{}, timezone interface{}) interface{}

DateHour takes a date and returnst the hour

func DateISODayOfWeek

func DateISODayOfWeek(date interface{}, timezone interface{}) interface{}

DateISODayOfWeek takes a date and returns the ISO day of the week

func DateISOWeek

func DateISOWeek(date interface{}, timezone interface{}) interface{}

DateISOWeek takes a date and returns the ISO week

func DateISOWeekYear

func DateISOWeekYear(date interface{}, timezone interface{}) interface{}

DateISOWeekYear takes a date and returns the ISO week year

func DateMillisecond

func DateMillisecond(date interface{}, timezone interface{}) interface{}

DateMillisecond takes a date and returns the milliseconds

func DateMinute

func DateMinute(date interface{}, timezone interface{}) interface{}

DateMinute takes a date and returns the minutes

func DateMonth

func DateMonth(date interface{}, timezone interface{}) interface{}

DateMonth takes a date and returns the month

func DateSecond

func DateSecond(date interface{}, timezone interface{}) interface{}

DateSecond takes a date and returns the seconds

func DateToString

func DateToString(date interface{}, format interface{}, timezone interface{}, onNull interface{}) interface{}

DateToString takes a date and formats it into a string

func DateWeek

func DateWeek(date interface{}, timezone interface{}) interface{}

DateWeek takes a date and returns the week

func DateYear

func DateYear(date interface{}, timezone interface{}) interface{}

DateYear takes a date and returns the year

func Equals

func Equals(expression1 interface{}, expression2 interface{}) interface{}

Equals returns true if the two expressions are equal

func Fori

func Fori(start interface{}, end interface{}, step interface{}) interface{}

Fori returns an array with numbers between start and end incremented by step

func GreaterThan

func GreaterThan(expression1 interface{}, expression2 interface{}) interface{}

GreaterThan is true if expression1 is greater than expression2

func GreaterThanOrEqual

func GreaterThanOrEqual(expression1 interface{}, expression2 interface{}) interface{}

GreaterThanOrEqual is true if expression1 is greater than or equal to expression2

func IfNull

func IfNull(expression interface{}, replacement interface{}) interface{}

IfNull evaluates expression and if it is null uses replacement expression instead

func IsArray

func IsArray(expression interface{}) interface{}

IsArray returns true if the expression evaluates to an array

func LessThan

func LessThan(expression1 interface{}, expression2 interface{}) interface{}

LessThan matches is true if expression1 is less to expression2

func LessThanOrEqual

func LessThanOrEqual(expression1 interface{}, expression2 interface{}) interface{}

LessThanOrEqual is true if expression1 is less than or equal to expression2

func Let

func Let(vars interface{}, expression interface{}) interface{}

Let specifies some variables to use in the expression

func Literal

func Literal(data interface{}) interface{}

Literal makes arbitrary data an expression without parsing

func MathAbs

func MathAbs(n interface{}) interface{}

MathAbs is the absolute value of a value

func MathAdd

func MathAdd(expressions ...interface{}) interface{}

MathAdd adds all values together

func MathAvg

func MathAvg(expression interface{}) interface{}

MathAvg takes an expression, evaluates it to an array and returns the single average value of the items in the array or MathAvg takes an array and returns the single average value of the items in the array

func MathCeil

func MathCeil(n interface{}) interface{}

MathCeil returns the smallest integer greater than or equal to the specified number

func MathDivide

func MathDivide(numerator interface{}, denominator interface{}) interface{}

MathDivide devides the numerator by the denominator and returns the result

func MathExp

func MathExp(n interface{}) interface{}

MathExp returns the e^n (e = Euler's number)

func MathFloor

func MathFloor(n interface{}) interface{}

MathFloor returns the largest integer less than or equal to the specified number

func MathLn

func MathLn(n interface{}) interface{}

MathLn returns the natural log of n (loge(n))

func MathLog

func MathLog(n interface{}, base interface{}) interface{}

MathLog returns the log of n with base 'base'

func MathLog10

func MathLog10(n interface{}) interface{}

MathLog10 returns the base10 log of n

func MathMod

func MathMod(numerator interface{}, denominator interface{}) interface{}

MathMod devides the numerator by the denominator and returns the remainder

func MathMultiply

func MathMultiply(expression1 interface{}, expression2 interface{}) interface{}

MathMultiply multiplies expression1 and expression2 and returns the result

func MathPower

func MathPower(base interface{}, exponent interface{}) interface{}

MathPower returns base to the power of exponent

func MathSquareRoot

func MathSquareRoot(n interface{}) interface{}

MathSquareRoot returns the square root of n

func MathStdDevPopulation

func MathStdDevPopulation(population interface{}) interface{}

MathStdDevPopulation returns the population standard deviation for the selected data

func MathStdDevSample

func MathStdDevSample(sample interface{}) interface{}

MathStdDevSample returns the sample standard deviation for the selected data

func MathSubtract

func MathSubtract(value1 interface{}, value2 interface{}) interface{}

MathSubtract returns value1 - value2

func MathSum

func MathSum(array ...interface{}) interface{}

MathSum adds all values in an array together

func MathTrunc

func MathTrunc(n interface{}) interface{}

MathTrunc returns the number with all decimal places removed

func NOT

func NOT(expression interface{}) interface{}

NOT inverts the expression

func NotEqual

func NotEqual(expression1 interface{}, expression2 interface{}) interface{}

NotEqual checks if expression1 and expression2 are equal

func OR

func OR(expressions ...interface{}) interface{}

OR is true if all expressions evaluate as true

func ObjectToArray

func ObjectToArray(expression interface{}) interface{}

ObjectToArray turns an object into an array of kv objects

func SetDifference

func SetDifference(array1 interface{}, array2 interface{}) interface{}

SetDifference returns all distinct items that exist in array 1 but not array 2

func SetEquals

func SetEquals(arrays ...interface{}) interface{}

SetEquals returns true if all arrays contain the same distinct elements (order and amount does not matter)

func SetIntersect

func SetIntersect(arrays ...interface{}) interface{}

SetIntersect returns all distinct items that appear in all arrays

func SetIsSubset

func SetIsSubset(array1 interface{}, array2 interface{}) interface{}

SetIsSubset returns true if all items from set1 exist in set2

func SetUnion

func SetUnion(arrays ...interface{}) interface{}

SetUnion returns an array with all unique items from all arrays

func StringCaseCompare

func StringCaseCompare(string1 interface{}, string2 interface{}) interface{}

StringCaseCompare compares the string case insensitvely 1 if first string is “greater than” the second string 0 if the two strings are equal -1 if the first string is “less than” the second string

func StringConcat

func StringConcat(strings ...interface{}) interface{}

StringConcat takes an array of expressions that evaluate to string and return the joined string of these

func StringIndexByte

func StringIndexByte(stringToBeSearched interface{}, substring interface{}, start interface{}, end interface{}) interface{}

StringIndexByte returns the index of the first match of substing on the string between start and end indexes (zero based UTF-8 byte index). Returns -1 if substring can not be found

func StringIndexCP

func StringIndexCP(stringToBeSearched interface{}, substring interface{}, start interface{}, end interface{}) interface{}

StringIndexCP returns the index of the first match of substing on the string between start and end indexes (zero based UTF-8 code point). Returns -1 if substring can not be found

func StringLengthBytes

func StringLengthBytes(stringToCheck interface{}) interface{}

StringLengthBytes returns the number of UTF-8 encoded bytes in the specified string

func StringLengthCP

func StringLengthCP(stringToCheck interface{}) interface{}

StringLengthCP returns the number of UTF-8 code points in the specified string

func StringSplit

func StringSplit(stringToSplit interface{}, delimiter interface{}) interface{}

StringSplit returns an array of substrings that come from the original string split at the delimiter

func StringSubstring

func StringSubstring(intialString interface{}, start interface{}, length interface{}) interface{}

StringSubstring returns the a substring of a specified length starting at a certain position (zero point char based)

func StringSubstringBytes

func StringSubstringBytes(intialString interface{}, index interface{}, count interface{}) interface{}

StringSubstringBytes returns the a substring with a specified count of UTF-8 bytes starting at a certain index (zero point UTF-8 byte index based)

func StringSubstringCP

func StringSubstringCP(intialString interface{}, index interface{}, count interface{}) interface{}

StringSubstringCP returns the a substring with a specified count of UTF-8 code points starting at a certain index (zero point UTF-8 code point based)

func StringToLower

func StringToLower(value interface{}) interface{}

StringToLower turns a value into a lowercase string

func StringToUpper

func StringToUpper(value interface{}) interface{}

StringToUpper turns a value into an uppercase string

func StringTrim

func StringTrim(input interface{}, chars interface{}) interface{}

StringTrim returns the input with chars trimmed from prefix and suffix

func StringTrimPrefix

func StringTrimPrefix(input interface{}, chars interface{}) interface{}

StringTrimPrefix returns the input with chars trimmed from prefix

func StringTrimSuffix

func StringTrimSuffix(input interface{}, chars interface{}) interface{}

StringTrimSuffix returns the input with chars trimmed from end

func Switch

func Switch(def interface{}, branches ...SwitchBranch) interface{}

Switch checks which case applies and then evalutes that expression. If none match, default is used

func ToBool

func ToBool(value interface{}) interface{}

ToBool turns a value into a bool

func ToDate

func ToDate(value interface{}) interface{}

ToDate turns a value into a date

func ToDecimal

func ToDecimal(value interface{}) interface{}

ToDecimal turns a value into a decimal

func ToDouble

func ToDouble(value interface{}) interface{}

ToDouble turns a value into a double

func ToInt

func ToInt(value interface{}) interface{}

ToInt turns a value into a int

func ToLong

func ToLong(value interface{}) interface{}

ToLong turns a value into a long

func ToObjectID

func ToObjectID(value interface{}) interface{}

ToObjectID turns a value into an object id

func ToString

func ToString(value interface{}) interface{}

ToString turns a value into a string

func Type

func Type(value interface{}) interface{}

Type returns the type of the value

func Value

func Value(field string) interface{}

Value is the value of a field in the document

Types

type SwitchBranch

type SwitchBranch struct {
	Case interface{}
	Then interface{}
}

SwitchBranch is a branch to switch on

Jump to

Keyboard shortcuts

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