Class: MongoQL::Expression
Defined Under Namespace
Classes: Ascend, Binary, Condition, DateNode, Descend, FieldNode, MethodCall, Projection, Unary, ValueNode
Constant Summary
collapse
- FORMATING_OPS =
{
"to_object_id": "$toObjectId",
"to_id": "$toObjectId",
"to_s": "$toString",
"to_string": "$toString",
"to_int": "$toInt",
"to_long": "$toLong",
"to_bool": "$toBool",
"to_date": "$toDate",
"to_decimal": "$toDecimal",
"to_double": "$toDouble",
"downcase": "$toLower",
"to_lower": "$toLower",
"upcase": "$toUpper",
"to_upper": "$toUpper"
}.freeze
CollectionOperators::AGGREGATE_OPS
UnaryOperators::UNARY_OPS
BinaryOperators::BINARY_OPS
Instance Method Summary
collapse
#concat, #substr, #trim
#any?, #concat_arrays, #contains, #filter, #map, #reduce
Instance Method Details
#if_null(default_val) ⇒ Object
Also known as:
default
44
45
46
47
48
|
# File 'lib/mongo_ql/expression.rb', line 44
def if_null(default_val)
Expression::MethodCall.new "$ifNull", self, ast_template: -> (target, **_args) {
[target, to_expression(default_val)]
}
end
|
#then(then_expr = nil, &block) ⇒ Object
55
56
57
|
# File 'lib/mongo_ql/expression.rb', line 55
def then(then_expr = nil, &block)
Expression::Condition.new(self, then_expr, nil, &block)
end
|
#to_ast ⇒ Object
59
60
61
|
# File 'lib/mongo_ql/expression.rb', line 59
def to_ast
raise NotImplementedError, "#{self.class.name} must implement to_ast"
end
|