package policiesdb

import (
	"context"

	"github.com/tech/sendico/pkg/db/repository"
	"github.com/tech/sendico/pkg/model"
	mutil "github.com/tech/sendico/pkg/mutil/db"
	"go.mongodb.org/mongo-driver/v2/bson"
)

func (db *PoliciesDB) Policies(ctx context.Context, refs []bson.ObjectID) ([]model.PolicyDescription, error) {
	if len(refs) == 0 {
		return []model.PolicyDescription{}, nil
	}
	filter := repository.Query().In(repository.IDField(), refs)
	return mutil.GetObjects[model.PolicyDescription](ctx, db.Logger, filter, nil, db.Repository)
}
