droboticflow/internal/store/query_collection_interface.go

37 lines
2.0 KiB
Go

package store
import (
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// Internal SDK seam: read helpers accept both ordinary collections and the
// source adapter that atomically tags writes. No business rule lives here.
type mongoCollection interface {
Name() string
Database() *mongo.Database
Indexes() mongo.IndexView
Find(context.Context, any, ...*options.FindOptions) (*mongo.Cursor, error)
FindOne(context.Context, any, ...*options.FindOneOptions) *mongo.SingleResult
Aggregate(context.Context, any, ...*options.AggregateOptions) (*mongo.Cursor, error)
InsertOne(context.Context, any, ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
InsertMany(context.Context, []any, ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
UpdateOne(context.Context, any, any, ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany(context.Context, any, any, ...*options.UpdateOptions) (*mongo.UpdateResult, error)
ReplaceOne(context.Context, any, any, ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
DeleteOne(context.Context, any, ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany(context.Context, any, ...*options.DeleteOptions) (*mongo.DeleteResult, error)
FindOneAndUpdate(context.Context, any, any, ...*options.FindOneAndUpdateOptions) *mongo.SingleResult
FindOneAndReplace(context.Context, any, any, ...*options.FindOneAndReplaceOptions) *mongo.SingleResult
FindOneAndDelete(context.Context, any, ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
BulkWrite(context.Context, []mongo.WriteModel, ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
CountDocuments(context.Context, any, ...*options.CountOptions) (int64, error)
EstimatedDocumentCount(context.Context, ...*options.EstimatedDocumentCountOptions) (int64, error)
Distinct(context.Context, string, any, ...*options.DistinctOptions) ([]any, error)
Drop(context.Context) error
}
var _ mongoCollection = (*mongo.Collection)(nil)
var _ mongoCollection = (*queryCollection)(nil)