package mongo

import (
	"context"

	"github.com/zeromicro/go-zero/core/stores/mon"
	"go.mongodb.org/mongo-driver/v2/mongo"
	mopt "go.mongodb.org/mongo-driver/v2/mongo/options"
)

type DocumentDBUseCase interface {
	PopulateIndex(ctx context.Context, key string, sort int32, unique bool)
	PopulateTTLIndex(ctx context.Context, key string, sort int32, unique bool, ttl int32)
	PopulateMultiIndex(ctx context.Context, keys []string, sorts []int32, unique bool)
	PopulateSparseMultiIndex(ctx context.Context, keys []string, sorts []int32, unique bool)
	GetClient() *mon.Model
}

type DocumentDBWithCacheUseCase interface {
	DocumentDBUseCase
	CacheUseCase
	DeleteOne(ctx context.Context, key string, filter any, opts ...*mopt.DeleteOneOptions) (int64, error)
	FindOne(ctx context.Context, key string, v, filter any, opts ...*mopt.FindOneOptions) error
	FindOneAndDelete(ctx context.Context, key string, v, filter any, opts ...*mopt.FindOneAndDeleteOptions) error
	FindOneAndReplace(ctx context.Context, key string, v, filter, replacement any, opts ...*mopt.FindOneAndReplaceOptions) error
	InsertOne(ctx context.Context, key string, document any, opts ...*mopt.InsertOneOptions) (*mongo.InsertOneResult, error)
	UpdateByID(ctx context.Context, key string, id, update any, opts ...*mopt.UpdateOneOptions) (*mongo.UpdateResult, error)
	UpdateMany(ctx context.Context, keys []string, filter, update any, opts ...*mopt.UpdateManyOptions) (*mongo.UpdateResult, error)
	UpdateOne(ctx context.Context, key string, filter, update any, opts ...*mopt.UpdateOneOptions) (*mongo.UpdateResult, error)
}

type CacheUseCase interface {
	DelCache(ctx context.Context, keys ...string) error
	GetCache(key string, v any) error
	SetCache(key string, v any) error
}
