Files
sendico/api/pkg/db/tseries/tseries.go
Stephan D 62a6631b9a
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
service backend
2025-11-07 18:35:26 +01:00

30 lines
992 B
Go

package tseries
import (
"context"
"time"
"github.com/tech/sendico/pkg/db/repository/builder"
rdecoder "github.com/tech/sendico/pkg/db/repository/decoder"
tspoint "github.com/tech/sendico/pkg/db/tseries/point"
)
// TimeSeries[T] abstracts a Mongo time-series “bucket” of documents of type T.
type TimeSeries interface {
// Aggregate runs an aggregation pipeline on the time-series
Aggregate(ctx context.Context, builder builder.Pipeline, decoder rdecoder.DecodingFunc) error
// Insert adds a single point into the series.
Insert(ctx context.Context, point tspoint.TimePoint) error
// InsertMany adds multiple points in one bulk operation.
InsertMany(ctx context.Context, points []tspoint.TimePoint) error
// Query fetches all points whose timeField lies in [from, to).
// The 'filter' param is an optional Mongo-style query on meta or other fields.
Query(
ctx context.Context,
decoder rdecoder.DecodingFunc,
filter builder.Query,
from, to *time.Time,
) error
}