func (c *Store) Put(document models.EncryptedDocument) error {
	err := c.validateNewDocIndexAttribute(document)
	if err != nil {
		return fmt.Errorf("failure during encrypted document validation: %w", err)
	}
	return c.UpsertBulk([]models.EncryptedDocument{document})
}
Put stores the given document.
Mapping documents are also created and stored in order to allow for encrypted indices to work.
package edvprovider
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/google/uuid"
	"github.com/hyperledger/aries-framework-go/spi/storage"
	"github.com/trustbloc/edge-core/pkg/log"
	"github.com/trustbloc/edv/pkg/edvutils"
	"github.com/trustbloc/edv/pkg/restapi/messages"
	"github.com/trustbloc/edv/pkg/restapi/models"
)
const (
	logModuleName = "edv-provider"
	VaultConfigurationStoreName = "data_vault_configurations"
	VaultConfigReferenceIDTagName = "ReferenceID"
	MappingDocumentTagName = "AttributeName"
	MappingDocumentMatchingEncryptedDocIDTagName = "MatchingEncryptedDocumentID"
)
var logger = log.New(logModuleName)
var errIndexNameAndValueAlreadyDeclaredUnique = errors.New("unable to store document since it contains an " +
	"index name and value that are already declared as unique in an existing document")
var errIndexNameAndValueCannotBeUnique = errors.New("unable to store document since it contains an " +
	"index name and value that are declared as unique, but another document already has an " +
	"identical index name + value pair")
type indexMappingDocument struct {
	AttributeName          string `json:"attributeName"`
	MatchingEncryptedDocID string `json:"matchingEncryptedDocID"`
	MappingDocumentName    string `json:"mappingDocumentName"`
}
type (
	checkIfBase58Encoded128BitValueFunc func(id string) error
	base58Encoded128BitToUUIDFunc       func(name string) (string, error)
)
type Provider struct {
	coreProvider                    storage.Provider
	retrievalPageSize               uint
	checkIfBase58Encoded128BitValue checkIfBase58Encoded128BitValueFunc
	base58Encoded128BitToUUID       base58Encoded128BitToUUIDFunc
}
func NewProvider(ariesProvider storage.Provider, retrievalPageSize uint) *Provider {
	return &Provider{
		coreProvider:                    ariesProvider,
		retrievalPageSize:               retrievalPageSize,
		checkIfBase58Encoded128BitValue: edvutils.CheckIfBase58Encoded128BitValue,
		base58Encoded128BitToUUID:       edvutils.Base58Encoded128BitToUUID,
	}
}
func (c *Provider) StoreExists(name string) (bool, error) {
	storeName, err := c.determineStoreNameToUse(name)
	if err != nil {
		return false, fmt.Errorf("failed to determine store name to use: %w", err)
	}
	_, err = c.coreProvider.GetStoreConfig(storeName)
	if err != nil {
		if errors.Is(err, storage.ErrStoreNotFound) {
			return false, nil
		}
		return false, fmt.Errorf("unexpected error while getting store config: %w", err)
	}
	return true, nil
}
func (c *Provider) OpenStore(name string) (*Store, error) {
	storeName, err := c.determineStoreNameToUse(name)
	if err != nil {
		return nil, fmt.Errorf("failed to determine store name to use: %w", err)
	}
	coreStore, err := c.coreProvider.OpenStore(storeName)
	if err != nil {
		return nil, err
	}
	return &Store{coreStore: coreStore, name: name, retrievalPageSize: c.retrievalPageSize}, nil
}
func (c *Provider) SetStoreConfig(name string, config storage.StoreConfiguration) error {
	storeName, err := c.determineStoreNameToUse(name)
	if err != nil {
		return fmt.Errorf("failed to determine store name to use: %w", err)
	}
	return c.coreProvider.SetStoreConfig(storeName, config)
}
type Store struct {
	coreStore         storage.Store
	name              string
	retrievalPageSize uint
}