36 lines
838 B
Go
36 lines
838 B
Go
package builderimp
|
|
|
|
import (
|
|
"git.sendico.io/tech/sxchnge/shared/database/repository/builder"
|
|
"go.mongodb.org/mongo-driver/v2/bson"
|
|
)
|
|
|
|
type groupAccumulatorImp struct {
|
|
field builder.Field
|
|
acc builder.Accumulator
|
|
}
|
|
|
|
// NewGroupAccumulator creates a new GroupAccumulator for the given field using the specified operator and value.
|
|
func NewGroupAccumulator(field builder.Field, acc builder.Accumulator) builder.GroupAccumulator {
|
|
return &groupAccumulatorImp{
|
|
field: field,
|
|
acc: acc,
|
|
}
|
|
}
|
|
|
|
func (g *groupAccumulatorImp) Field() builder.Field {
|
|
return g.field
|
|
}
|
|
|
|
func (g *groupAccumulatorImp) Accumulator() builder.Accumulator {
|
|
return g.acc
|
|
}
|
|
|
|
// Build returns a bson.E element for this group accumulator.
|
|
func (g *groupAccumulatorImp) Build() bson.D {
|
|
return bson.D{{
|
|
Key: g.field.Build(),
|
|
Value: g.acc.Build(),
|
|
}}
|
|
}
|