$indexOfBytes
, $strLenBytes, $substrBytes, $toDate,
$toObjectId and the date expression operators. Accumulators are also not supported. Only
the aggregation variables $$NOW and $$ROOT are supported. The extension
variable $$TODAY returns the current date as an ISO 8601 string.
The $unescape extension operator converts key names that start with "#$" to "$".
This way an expression can be escaped from implementation generation.
The expression of the $jslt extension operator should be an object with the
fields input and script. The former is an expression that should
produce a JSON value. If it is absent $$ROOT will be assumed. The latter is a
reference to a JSLT script. If the value starts with "resource:" then it is treated as a resource
in the class path. Otherwise, it is a filename or a script. The result of the expression will be a
JSON value. If the expression is just a string, then it will ba handled as a script value.
The $sort extension operator receives an object with the mandatory field
input, which should be an expression that yields an array. The optional field
direction can have the values "asc" or "desc", the former being the default. The optional
field paths is a list of field paths. When it is present only object values in the
array are considered. They will be sorted hierarchically with the values extracted with the
paths.
The operator $elemMatch, which is normally part of the MongoDB query language, is
available in another form. Its value must be an array with two elements. The first element is an
expression that yields an array and the second is an $elemMatch specification. If
behaves as the projection
variant of the operator.
If you wrap an expression in the $trace operator then tracing will be done for it
in the logger "net.pincette.mongo.expressions" at level INFO.
- Since:
- 1.2
- Author:
- Werner Donné
-
Method Summary
Modifier and TypeMethodDescriptionstatic Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Function<JsonObject,JsonValue> Constructs a function withexpression.static Implementationimplementation(JsonValue expression, Features features) Extension developers can use this to delegate implementation generation to subexpressions.static Loggerlogger()If you set the log level to FINEST you will get a trace.static ImplementationmemberFunction(JsonValue expression, String name, Features features) Ifexpressionis an object, which has a subexpression calledname, then this method returns the implementation of the subexpression.static List<Implementation>memberFunctions(JsonValue expression, String name, Features features) Ifexpressionis an object, which has a subexpression calledname, and if the subexpression is actually an array of subexpressions, then this method returns the implementation of the subexpressions.static JsonValuereplaceVariables(JsonValue expression, Map<String, JsonValue> variables) Replaces allvariablesinexpression.
-
Method Details
-
function
Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.- Returns:
- The function, which is stateless.
- Since:
- 1.2
-
function
Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.features- extra features. It may benull.- Returns:
- The function, which is stateless.
- Since:
- 2.0
-
function
public static Function<JsonObject,JsonValue> function(JsonValue expression, Map<String, JsonValue> variables) Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.variables- external variables. It may benull.- Returns:
- The function, which is stateless.
- Since:
- 1.3
-
function
public static Function<JsonObject,JsonValue> function(JsonValue expression, Map<String, JsonValue> variables, Features features) Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.variables- external variables. It may benull.features- extra features. It may benull.- Returns:
- The function, which is stateless.
- Since:
- 2.0
-
function
Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.- Returns:
- The function, which is stateless.
- Since:
- 1.2
-
function
Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.features- extra features. It may benull.- Returns:
- The function, which is stateless.
- Since:
- 2.0
-
function
public static Function<JsonObject,JsonValue> function(Bson expression, Map<String, JsonValue> variables) Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.variables- external variables.- Returns:
- The function, which is stateless.
- Since:
- 1.3
-
function
public static Function<JsonObject,JsonValue> function(Bson expression, Map<String, JsonValue> variables, Features features) Constructs a function withexpression.- Parameters:
expression- the MongoDB expression.variables- external variables.features- extra features. It may benull.- Returns:
- The function, which is stateless.
- Since:
- 2.0
-
implementation
Extension developers can use this to delegate implementation generation to subexpressions.- Parameters:
expression- the given expression.features- extra features. It may benull.- Returns:
- The generated implementation.
- Since:
- 2.0
-
logger
If you set the log level to FINEST you will get a trace.- Returns:
- The logger with the name "net.pincette.mongo.expression".
- Since:
- 1.3
-
memberFunction
Ifexpressionis an object, which has a subexpression calledname, then this method returns the implementation of the subexpression.- Parameters:
expression- the given expression.name- the name of the subexpression.features- extra features. It may benull.- Returns:
- The implementation of the subexpression. If
expressionis not an object or if the subexpression is invalidnullwill be returned. - Since:
- 2.0
-
memberFunctions
public static List<Implementation> memberFunctions(JsonValue expression, String name, Features features) Ifexpressionis an object, which has a subexpression calledname, and if the subexpression is actually an array of subexpressions, then this method returns the implementation of the subexpressions.- Parameters:
expression- the given expression.name- the name of the subexpressions.features- extra features. It may benull.- Returns:
- The implementation of the subexpressions. If
expressionis not an object or if the subexpressions are invalidnullwill be returned. - Since:
- 2.0
-
replaceVariables
Replaces allvariablesinexpression. Variable names start with "$$".- Parameters:
expression- the given expression.variables- maps variable names to JSON values.- Returns:
- The new expression.
- Since:
- 1.3.2
-