class MongoQL::Stage::Group

Attributes

by[RW]
ctx[RW]
fields[RW]

Public Class Methods

new(ctx, by, arrow_fields = {}, **fields) click to toggle source
# File lib/mongo_ql/stage/group.rb, line 8
def initialize(ctx, by, arrow_fields = {}, **fields)
  @ctx    = ctx
  @by     = by
  @fields = fields.transform_keys(&:to_s).merge(arrow_fields.transform_keys(&:to_s))
end

Public Instance Methods

to_ast() click to toggle source
# File lib/mongo_ql/stage/group.rb, line 14
def to_ast
  ast = {
    "$group" => {
      "_id" => by,
    }.merge(fields)
  }
  MongoQL::Utils.deep_transform_values(ast, &MongoQL::EXPRESSION_TO_AST_MAPPER)
end