v0.0.363 wmo.extraModPipeline as func
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m9s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m9s
This commit is contained in:
@@ -45,7 +45,7 @@ type Coll[TData any] struct {
|
||||
customDecoder *func(ctx context.Context, dec Decodable) (TData, error) // custom decoding function (useful if TData is an interface)
|
||||
isInterfaceDataType bool // true if TData is an interface (not a struct)
|
||||
unmarshalHooks []func(d TData) TData // called for every object after unmarshalling
|
||||
extraModPipeline mongo.Pipeline // appended to pipelines after filter/limit/skip/sort, used for $lookup, $set, $unset, $project, etc
|
||||
extraModPipeline []func(ctx context.Context) mongo.Pipeline // appended to pipelines after filter/limit/skip/sort, used for $lookup, $set, $unset, $project, etc
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) Collection() *mongo.Collection {
|
||||
@@ -83,7 +83,13 @@ func (c *Coll[TData]) WithUnmarshalHook(fn func(d TData) TData) *Coll[TData] {
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) WithModifyingPipeline(p mongo.Pipeline) *Coll[TData] {
|
||||
c.extraModPipeline = append(c.extraModPipeline, p...)
|
||||
c.extraModPipeline = append(c.extraModPipeline, func(ctx context.Context) mongo.Pipeline { return p })
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) WithModifyingPipelineFunc(fn func(ctx context.Context) mongo.Pipeline) *Coll[TData] {
|
||||
c.extraModPipeline = append(c.extraModPipeline, fn)
|
||||
|
||||
return c
|
||||
}
|
||||
|
Reference in New Issue
Block a user