Documentation ¶
Index ¶
- Constants
- Variables
- type BasicRepo
- func (r *BasicRepo) DeleteData(_ context.Context, uid, id string) error
- func (r *BasicRepo) GetAllDataByType(_ context.Context, uid string, t StorageType) ([]SecureData, error)
- func (r *BasicRepo) GetDataByID(_ context.Context, uid, id string) (SecureData, error)
- func (r *BasicRepo) StoreData(_ context.Context, data SecureData) (string, error)
- type DBRepo
- func (r *DBRepo) DeleteData(ctx context.Context, uid, id string) error
- func (r *DBRepo) GetAllDataByType(ctx context.Context, uid string, t StorageType) ([]SecureData, error)
- func (r *DBRepo) GetDataByID(ctx context.Context, uid, id string) (SecureData, error)
- func (r *DBRepo) StoreData(ctx context.Context, data SecureData) (string, error)
- type IRepository
- type SecureData
- type Service
- func (s Service) DeleteSecureData(ctx context.Context, uid, id string) error
- func (s Service) GetAllDataByType(ctx context.Context, uid string, t StorageType) ([]SecureData, error)
- func (s Service) GetDataByID(ctx context.Context, uid, id string) (SecureData, error)
- func (s Service) GetDataFromBytes(b []byte) ([]byte, error)
- func (s Service) StoreSecureDataFromPayload(ctx context.Context, uid string, payload any, t StorageType) (string, error)
- type Storage
- type StorageType
Constants ¶
View Source
const ( CreateStorageTable = `` /* 260-byte string literal not displayed */ DeleteData = "DELETE FROM storage WHERE uid = $1 AND id = $2" GetAllDataByType = "SELECT * FROM storage WHERE uid = $1 AND type = $2" GetDataByID = "SELECT * FROM storage WHERE uid = $1 AND id = $2" StoreData = ` INSERT INTO storage(uid, data, type) VALUES($1, $2, $3) ON CONFLICT DO NOTHING RETURNING id ` )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BasicRepo ¶
type BasicRepo struct {
// contains filtered or unexported fields
}
func NewBasicRepo ¶
func NewBasicRepo() *BasicRepo
func (*BasicRepo) DeleteData ¶
func (*BasicRepo) GetAllDataByType ¶
func (r *BasicRepo) GetAllDataByType(_ context.Context, uid string, t StorageType, ) ([]SecureData, error)
func (*BasicRepo) GetDataByID ¶
type DBRepo ¶
type DBRepo struct {
// contains filtered or unexported fields
}
func (*DBRepo) GetAllDataByType ¶
func (r *DBRepo) GetAllDataByType(ctx context.Context, uid string, t StorageType, ) ([]SecureData, error)
func (*DBRepo) GetDataByID ¶
type IRepository ¶
type IRepository interface { DeleteData(ctx context.Context, uid, id string) error GetAllDataByType(ctx context.Context, uid string, t StorageType) ([]SecureData, error) GetDataByID(ctx context.Context, uid, id string) (SecureData, error) StoreData(ctx context.Context, data SecureData) (string, error) }
func NewRepo ¶
func NewRepo(repoURL string) (IRepository, error)
type SecureData ¶
type SecureData struct { UID string `json:"-"` ID string `json:"id"` Data []byte `json:"data"` Type StorageType `json:"-"` }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
NewService returns an instance of the Service with the associated repository. The repository gets created in accordance with the passed URL.
func (Service) DeleteSecureData ¶
DeleteSecureData removes the stored data with the unique ID. The method removes the data of the specified user only.
func (Service) GetAllDataByType ¶
func (s Service) GetAllDataByType(ctx context.Context, uid string, t StorageType) ([]SecureData, error)
GetAllDataByType returns all the user's stored data.
func (Service) GetDataByID ¶
GetDataByID returns the stored data by the unique ID. The method returns the data of the specified user only.
func (Service) GetDataFromBytes ¶
GetDataFromBytes transforms the encrypted slice of bytes into the original one.
func (Service) StoreSecureDataFromPayload ¶
func (s Service) StoreSecureDataFromPayload(ctx context.Context, uid string, payload any, t StorageType, ) (string, error)
StoreSecureDataFromPayload processes payload of any type into a slice of bytes, encodes the slice, and stores the content in the DB.
Click to show internal directories.
Click to hide internal directories.