Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Unmarshal ¶
func Unmarshal(input jsoniter.RawMessage) (expression.Expr, error)
Unmarshal to unmarshal an aggregation object.
func UnmarshalAggObject ¶
func UnmarshalAggObject(input jsoniter.RawMessage) (expression.Expr, error)
UnmarshalAggObject unmarshal the input to the aggregation. Note the return after the first check, this is mainly because an aggregation object can have nested objects but top level it will be one expression.
Types ¶
type AccumulatorFactory ¶
type AccumulatorFactory struct { Avg *AccumulatorOp `json:"$avg,omitempty"` Min *AccumulatorOp `json:"$min,omitempty"` Max *AccumulatorOp `json:"$max,omitempty"` Sum *AccumulatorOp `json:"$sum,omitempty"` }
AccumulatorFactory to return the object of the accumulator type.
func (*AccumulatorFactory) Get ¶
func (a *AccumulatorFactory) Get() Aggregation
type AccumulatorOp ¶
type AccumulatorOp struct { Type string Agg expression.Expr }
AccumulatorOp is a type of aggregation that can also be use in the group by to group values into subsets.
func (*AccumulatorOp) Apply ¶
func (a *AccumulatorOp) Apply(document jsoniter.RawMessage)
func (*AccumulatorOp) String ¶
func (a *AccumulatorOp) String() string
func (*AccumulatorOp) UnmarshalJSON ¶
func (a *AccumulatorOp) UnmarshalJSON(input []byte) error
type Aggregation ¶
type Aggregation interface {
Apply(document jsoniter.RawMessage)
}
Aggregation operators either can pass a single expression or an array of expression. The below is an example of how a caller can pass aggregation,
{ $aggregation: <expression> }
OR
{ $aggregation: [ <expression1>, <expression2> ... ] }
As an example, for sum across two fields the grammar would be,
{ "$sum": { "$multiply": ["$price", "$quantity"] } }
More examples,
{ "$sum": "$qty" }
{ "$sum": [ "$final", "$midterm" ] }}.
type ArithmeticFactory ¶
type ArithmeticFactory struct { Add *ArithmeticOp `json:"$add,omitempty"` Multiply *ArithmeticOp `json:"$multiply,omitempty"` }
ArithmeticFactory to return the object of the arithmeticOp type.
func (*ArithmeticFactory) Get ¶
func (a *ArithmeticFactory) Get() Aggregation
type ArithmeticOp ¶
type ArithmeticOp struct { Type string Agg expression.Expr }
func (*ArithmeticOp) Apply ¶
func (a *ArithmeticOp) Apply(document jsoniter.RawMessage)
func (*ArithmeticOp) String ¶
func (a *ArithmeticOp) String() string
func (*ArithmeticOp) UnmarshalJSON ¶
func (a *ArithmeticOp) UnmarshalJSON(input []byte) error