class MongoQL::Stage::Unwind

Attributes

allow_null[RW]
ctx[RW]
path[RW]

Public Class Methods

new(ctx, path, allow_null: false) click to toggle source
# File lib/mongo_ql/stage/unwind.rb, line 7
def initialize(ctx, path, allow_null: false)
  @ctx        = ctx
  @path       = to_expression(path)
  @allow_null = allow_null
end

Public Instance Methods

to_ast() click to toggle source
# File lib/mongo_ql/stage/unwind.rb, line 13
def to_ast
  ast = {
    "$unwind" => {
      "path" => path,
      "preserveNullAndEmptyArrays" => allow_null
    }
  }
  MongoQL::Utils.deep_transform_values(ast, &MongoQL::EXPRESSION_TO_AST_MAPPER)
end