relational

package
v0.0.0-...-2205d8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRelationalDAL

func NewRelationalDAL(db *gorm.DB) persistence.DataAccessLayer

NewRelationalDAL wraps the given *gorm.DB, exposing the default interface for data access layers.

Types

type Account

type Account struct {
	AccountID           string `gorm:"primary_key;size:36;unique"`
	Name                string
	PublicKey           string `gorm:"type:text"`
	EncryptedPrivateKey string `gorm:"type:text"`
	UserSalt            string
	Retired             bool
	AccountStyles       string `gorm:"type:text"`
	Created             time.Time
	Events              []Event `gorm:"foreignkey:AccountID;association_foreignkey:AccountID"`
}

Account stores information about an account.

type AccountUser

type AccountUser struct {
	AccountUserID  string `gorm:"primary_key;size:36;unique"`
	HashedEmail    string
	HashedPassword string
	Salt           string
	AdminLevel     int
	Relationships  []AccountUserRelationship `gorm:"foreignkey:AccountUserID;association_foreignkey:AccountUserID"`
}

AccountUser is a person that can log in and access data related to all associated accounts.

type AccountUserRelationship

type AccountUserRelationship struct {
	RelationshipID                    string `gorm:"primary_key;size:36;unique"`
	AccountUserID                     string `gorm:"size:36"`
	AccountID                         string `gorm:"size:36"`
	PasswordEncryptedKeyEncryptionKey string `gorm:"type:text"`
	EmailEncryptedKeyEncryptionKey    string `gorm:"type:text"`
	OneTimeEncryptedKeyEncryptionKey  string `gorm:"type:text"`
}

AccountUserRelationship contains the encrypted KeyEncryptionKeys needed for an AccountUser to access the data of the account it links to.

type Event

type Event struct {
	EventID   string `gorm:"primary_key;size:26;unique"`
	Sequence  string `gorm:"size:26"`
	AccountID string `gorm:"size:36"`
	// the secret id is nullable for anonymous events
	SecretID *string `gorm:"size:64"`
	Payload  string  `gorm:"type:text"`
	Secret   Secret  `gorm:"foreignkey:SecretID;association_foreignkey:SecretID"`
}

Event is any analytics event that will be stored in the database. It is uniquely tied to an Account and a Secret model.

type Secret

type Secret struct {
	SecretID        string `gorm:"primary_key;size:64;unique"`
	EncryptedSecret string `gorm:"type:text"`
}

Secret associates a hashed user id - which ties a user and account together uniquely - with the encrypted user secret the account owner can use to decrypt events stored for that user.

type Tombstone

type Tombstone struct {
	EventID   string  `gorm:"primary_key"`
	AccountID string  `gorm:"size:36"`
	SecretID  *string `gorm:"size:64"`
	Sequence  string  `gorm:"size:26"`
}

A Tombstone replaces an event on its deletion

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL