Class Function
A class for creating IExpression instances that represent functions
Inheritance
Inherited Members
Namespace: Couchbase.Lite.Query
Assembly: Couchbase.Lite.dll
Syntax
public static class Function
Methods
| Improve this Doc View SourceAbs(IExpression)
Creates a function that will get the absolute value of the expression in question
Declaration
public static IExpression Abs(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the absolute value of the expression in question |
Acos(IExpression)
Creates a function that will get the inverse cosine of the expression in question
Declaration
public static IExpression Acos(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the inverse cosine of the expression in question |
Asin(IExpression)
Creates a function that will get the inverse sin of the expression in question
Declaration
public static IExpression Asin(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the inverse sin of the expression in question |
Atan(IExpression)
Creates a function that will get the inverse tangent of the expression in question
Declaration
public static IExpression Atan(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the inverse tangent of the expression in question |
Atan2(IExpression, IExpression)
Creates a function that will get the arctangent of the point expressed by expressions calculating X and Y of the point for the formula
Declaration
public static IExpression Atan2(IExpression expressionX, IExpression expressionY)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expressionX | An expression or literal to evaluate to get the X coordinate to use |
IExpression | expressionY | An expression or literal to evaluate to get the Y coordinate to use |
Returns
Type | Description |
---|---|
IExpression | A function that will get the arctangent of the point in question |
Avg(IExpression)
Creates a function that will calculate the average of the expression in question across the results in a particular query
Declaration
public static IExpression Avg(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will calculate the average |
Ceil(IExpression)
Creates a function that will get the ceiling value of the expression in question
Declaration
public static IExpression Ceil(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the ceiling value of the expression in question |
Contains(IExpression, IExpression)
Creates a function that will calculate if a given string is inside of another in question
Declaration
public static IExpression Contains(IExpression expression, IExpression substring)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The string or expression that evaluates to a string to search |
IExpression | substring | The string or expression that evaluates to a string to search for |
Returns
Type | Description |
---|---|
IExpression | A function that will return true if the string contains the other, or false if it does not |
Cos(IExpression)
Creates a function that will get the cosine of the expression in question
Declaration
public static IExpression Cos(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the cosine of the expression in question |
CosineDistance(IExpression, IExpression)
Creates a function that returns the cosine distance between two vectors
of the same length.
The result of the calculation is a floating-point number in the range
[-1 ... +1] or null
.
Declaration
public static IExpression CosineDistance(IExpression expression1, IExpression expression2)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression1 | The first input vector |
IExpression | expression2 | The second input vector |
Returns
Type | Description |
---|---|
IExpression | An expression that can be further acted upon in the QueryBuilder |
Remarks
NOTE: This is an enterprise edition feature
Count(IExpression)
Creates a function that will count the occurrences of expression in question across the results in a particular query
Declaration
public static IExpression Count(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will calculate the count |
Degrees(IExpression)
Creates a function that will convert a numeric expression to degrees from radians in question
Declaration
public static IExpression Degrees(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the value of the expression in question expressed in degrees |
E()
Creates a function that will return the value of the mathemetical constant 'e'
Declaration
public static IExpression E()
Returns
Type | Description |
---|---|
IExpression | The value of 'e' |
EuclideanDistance(IExpression, IExpression)
Creates a function that returns the euclidean distance between two vectors
of the same length.
The result of the calculation is a positive floating-point number or null
.
Declaration
public static IExpression EuclideanDistance(IExpression expression1, IExpression expression2)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression1 | The first input vector |
IExpression | expression2 | The second input vector |
Returns
Type | Description |
---|---|
IExpression | An expression that can be further acted upon in the QueryBuilder |
Remarks
NOTE: This is an enterprise edition feature
Exp(IExpression)
Returns the mathematical constant 'e' raised to the given power
Declaration
public static IExpression Exp(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numerical expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the mathematical constant 'e' raised to the given power |
Floor(IExpression)
Creates a function that will get the floor value of the expression in question
Declaration
public static IExpression Floor(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the floor value of the expression in question |
Length(IExpression)
Creates a function that gets the length of a string in question
Declaration
public static IExpression Length(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result (must be or evaluate to a string) |
Returns
Type | Description |
---|---|
IExpression | The length of the string in question |
Ln(IExpression)
Creates a function that gets the natural log of the numerical expression
Declaration
public static IExpression Ln(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that gets the natural log of the expression |
Log(IExpression)
Creates a function that gets the base 10 log of the numerical expression
Declaration
public static IExpression Log(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that gets the base 10 log of the expression |
Lower(IExpression)
Creates a function that converts a string to lower case
Declaration
public static IExpression Lower(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that converts a string to lower case |
Ltrim(IExpression)
Creates a function that removes whitespace from the beginning of a string
Declaration
public static IExpression Ltrim(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that removes whitespace from the beginning of a string |
Max(IExpression)
Creates a function that will calculate the max value of the expression in question across the results in a particular query
Declaration
public static IExpression Max(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will calculate the max value |
MillisToString(IExpression)
Creates a function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in the device local time zone.
Declaration
public static IExpression MillisToString(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when converting |
Returns
Type | Description |
---|---|
IExpression | A function that will convert the timestamp to a string |
MillisToUTC(IExpression)
Creates a function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in UTC time.
Declaration
public static IExpression MillisToUTC(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when converting |
Returns
Type | Description |
---|---|
IExpression | A function that will convert the timestamp to a string |
Min(IExpression)
Creates a function that will calculate the min value of the expression in question across the results in a particular query
Declaration
public static IExpression Min(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will calculate the min value |
Pi()
Creates a function that will return the value of the mathemetical constant 'π'
Declaration
public static IExpression Pi()
Returns
Type | Description |
---|---|
IExpression | The value of 'π' |
Power(IExpression, IExpression)
Creates a function that will raise the given numeric expression to an expression that determines the exponent
Declaration
public static IExpression Power(IExpression b, IExpression exponent)
Parameters
Type | Name | Description |
---|---|---|
IExpression | b | A numeric literal or expression that provides the base |
IExpression | exponent | A numeric literal or expression that provides the exponent |
Returns
Type | Description |
---|---|
IExpression | A function that will raise the base to the given exponent |
Prediction(String, IExpression)
Creates a function that will invoke IPredictiveModel implementations to aid in machine learning predictive queries
Declaration
public static IPredictionFunction Prediction(string modelName, IExpression input)
Parameters
Type | Name | Description |
---|---|---|
System.String | modelName | The model (registered via RegisterModel(String, IPredictiveModel)) to use when performing the prediction |
IExpression | input | The input to feed to the model. This can be either an expression that is evaluated into a dictionary or a dictionary literal expression. |
Returns
Type | Description |
---|---|
IPredictionFunction |
Remarks
NOTE: This is an enterprise edition feature
Radians(IExpression)
Creates a function that will convert a numeric expression to radians from degrees in question
Declaration
public static IExpression Radians(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will get the value of the expression in question expressed in radians |
Round(IExpression)
Creates a function that will round the given expression in question
Declaration
public static IExpression Round(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will round the expression (using midpoint rounding) |
Round(IExpression, IExpression)
Creates a function that will round the given expression to the number of digits indicated in question
Declaration
public static IExpression Round(IExpression expression, IExpression digits)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
IExpression | digits | The number of digits to round to |
Returns
Type | Description |
---|---|
IExpression | A function that will round the expression (using midpoint rounding) |
Rtrim(IExpression)
Creates a function that removes whitespace from the end of a string
Declaration
public static IExpression Rtrim(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that removes whitespace from the end of a string |
Sign(IExpression)
Creates a function that returns the sign (positive, negative, or neither) of the expression in question
Declaration
public static IExpression Sign(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to evaluate |
Returns
Type | Description |
---|---|
IExpression | A function that returns the sign of the expression in question |
Sin(IExpression)
Creates a function that returns the sin of the expression in question
Declaration
public static IExpression Sin(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to evaluate |
Returns
Type | Description |
---|---|
IExpression | A function that returns the sin of the expression in question |
Sqrt(IExpression)
Creates a function that returns the square root of the expression in question
Declaration
public static IExpression Sqrt(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to evaluate |
Returns
Type | Description |
---|---|
IExpression | A function that returns the square root of the expression in question |
SquaredEuclideanDistance(IExpression, IExpression)
Creates a function that returns the squared euclidean distance between two vectors
of the same length.
The result of the calculation is a positive floating-point number or null
.
Declaration
public static IExpression SquaredEuclideanDistance(IExpression expression1, IExpression expression2)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression1 | The first input vector |
IExpression | expression2 | The second input vector |
Returns
Type | Description |
---|---|
IExpression | An expression that can be further acted upon in the QueryBuilder |
Remarks
NOTE: This is an enterprise edition feature
StringToMillis(IExpression)
Creates a function that will convert an ISO8601 datetime string into the number of milliseconds since the unix epoch.
Declaration
public static IExpression StringToMillis(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when converting |
Returns
Type | Description |
---|---|
IExpression | A function that will convert the string to a timestamp |
Remarks
Valid date strings must start with a date in the form YYYY-MM-DD (time only strings are not supported).
Times can be of the form HH:MM, HH:MM:SS, or HH:MM:SS.FFF. Leading zero is not optional (i.e. 02 is ok, 2 is not). Hours are in 24-hour format. FFF represents milliseconds, and trailing zeros are optional (i.e. 5 == 500).
Time zones can be in one of three forms: (+/-)HH:MM (+/-)HHMM Z (which represents UTC)
No time zone present will default to the device local time zone
StringToUTC(IExpression)
Creates a function that will convert an ISO8601 datetime string into a full ISO8601 UTC datetime string.
Declaration
public static IExpression StringToUTC(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when converting |
Returns
Type | Description |
---|---|
IExpression | A function that will convert the string to a timestamp |
Remarks
Valid date strings must start with a date in the form YYYY-MM-DD (time only strings are not supported).
Times can be of the form HH:MM, HH:MM:SS, or HH:MM:SS.FFF. Leading zero is not optional (i.e. 02 is ok, 2 is not). Hours are in 24-hour format. FFF represents milliseconds, and trailing zeros are optional (i.e. 5 == 500).
Time zones can be in one of three forms: (+/-)HH:MM (+/-)HHMM Z (which represents UTC)
No time zone present will default to the device local time zone
Sum(IExpression)
Creates a function that will calculate the sum of the expression in question across the results in a particular query
Declaration
public static IExpression Sum(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will calculate the sum |
Tan(IExpression)
Creates a function that returns the tangent of the expression in question
Declaration
public static IExpression Tan(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to evaluate |
Returns
Type | Description |
---|---|
IExpression | A function that returns the tangent of the expression in question |
Trim(IExpression)
Creates a function that removes whitespace from the start and end of a string
Declaration
public static IExpression Trim(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that removes whitespace from the start and end of a string |
Trunc(IExpression)
Creates a function that will truncate the given expression (i.e remove all the digits after the decimal place) in question
Declaration
public static IExpression Trunc(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that will truncate the expressoin |
Trunc(IExpression, IExpression)
Creates a function that will truncate the given expression to the number of digits indicated in question
Declaration
public static IExpression Trunc(IExpression expression, IExpression digits)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The numeric expression to take data from when calculating the result |
IExpression | digits | The number of digits to truncate to |
Returns
Type | Description |
---|---|
IExpression | A function that will truncate the expression |
Upper(IExpression)
Creates a function that converts a string to upper case
Declaration
public static IExpression Upper(IExpression expression)
Parameters
Type | Name | Description |
---|---|---|
IExpression | expression | The expression to take data from when calculating the result |
Returns
Type | Description |
---|---|
IExpression | A function that converts a string to upper case |