models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RequestStatusPending    RequestStatusType = "pending"
	RequestStatusProcessing RequestStatusType = "processing"
	RequestStatusCompleted  RequestStatusType = "completed"
	RequestStatusFailed     RequestStatusType = "failed"
	RequestStatusDuplicate  RequestStatusType = "duplicate"

	RequestOperationUpload    RequestOperationType = "post_upload"
	RequestOperationTusUpload RequestOperationType = "tus_upload"
	RequestOperationPin       RequestOperationType = "pin"
)

Variables

View Source
var (
	ErrTusLockBusy = errors.New("lock is currently held by another process")
)

Functions

func GetModels

func GetModels() []interface{}

Types

type AccessRule added in v0.2.0

type AccessRule struct {
	gorm.Model
	Ptype string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V0    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V1    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V2    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V3    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V4    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
	V5    string `gorm:"size:512;index:idx_access_rule,unique,length:100"`
}

type AccountDeletion added in v0.2.0

type AccountDeletion struct {
	gorm.Model
	IP     string
	UserID uint
	User   User
}

type CronJob

type CronJob struct {
	gorm.Model
	UUID          types.BinaryUUID `gorm:"type:binary(16);uniqueIndex"`
	Function      string           `gorm:"type:varchar(255);"`
	Args          string           `gorm:"type:longtext;"`
	LastRun       *time.Time
	Failures      uint64
	State         CronJobState `gorm:"type:varchar(20);default:'queued'"`
	LastHeartbeat *time.Time
	Version       uint64 `gorm:"default:0"`
}

func (*CronJob) BeforeCreate

func (t *CronJob) BeforeCreate(_ *gorm.DB) error

type CronJobLog added in v0.2.0

type CronJobLog struct {
	gorm.Model
	CronJobID uint
	CronJob   CronJob
	Type      CronJobLogType
	Message   string
}

type CronJobLogType added in v0.2.0

type CronJobLogType string
const (
	CronJobLogTypeFailure CronJobLogType = "failure"
)

type CronJobState added in v0.2.0

type CronJobState string
const (
	CronJobStateQueued     CronJobState = "queued"
	CronJobStateProcessing CronJobState = "processing"
	CronJobStateCompleted  CronJobState = "completed"
	CronJobStateFailed     CronJobState = "failed"
)

type EmailVerification

type EmailVerification struct {
	gorm.Model

	UserID    uint
	User      User
	NewEmail  string
	Token     string
	ExpiresAt time.Time
}

type PasswordReset

type PasswordReset struct {
	gorm.Model

	UserID    uint
	User      User
	Token     string
	ExpiresAt time.Time
}

type Pin

type Pin struct {
	gorm.Model
	UploadID uint
	Upload   Upload
	UserID   uint
	User     User
}

type PublicKey

type PublicKey struct {
	gorm.Model
	UserID uint
	Key    string `gorm:"unique;not null"`
	User   User
}

type Request added in v0.2.0

type Request struct {
	gorm.Model
	Operation         RequestOperationType `gorm:"index:idx_request_operation_system"`
	Protocol          string
	Status            RequestStatusType
	StatusMessage     string
	System            bool `gorm:"default:false;index:idx_request_operation_system"`
	UserID            uint
	User              User
	SourceIP          string
	HashType          uint64
	Hash              mh.Multihash `gorm:"type:varbinary(64);index"`
	CIDType           uint64       `gorm:"null;column:cid_type"`
	UploadHash        mh.Multihash `gorm:"type:varbinary(64);index"`
	UploadHashCIDType uint64       `gorm:"null;column:upload_hash_cid_type"`
	Size              uint64
	MimeType          string
	Metadata          datatypes.JSON
}

type RequestOperationType added in v0.2.0

type RequestOperationType string

type RequestStatusType added in v0.2.0

type RequestStatusType string

type S3Upload

type S3Upload struct {
	gorm.Model
	UploadID string `gorm:"unique;not null"`
	Bucket   string `gorm:"not null;index:idx_s3_bucket_key"`
	Key      string `gorm:"not null;index:idx_s3_bucket_key"`
}

type SCPriceHistory

type SCPriceHistory struct {
	gorm.Model
	CreatedAt time.Time       `gorm:"uniqueIndex:idx_time"`
	Rate      decimal.Decimal `gorm:"type:DECIMAL(30,20);index:idx_rate"`
}

func (SCPriceHistory) TableName

func (SCPriceHistory) TableName() string

type SiaUpload

type SiaUpload struct {
	gorm.Model
	UploadID string `gorm:"unique;not null"`
	Bucket   string `gorm:"not null;index:idx_sia_bucket_key"`
	Key      string `gorm:"not null;index:idx_sia_bucket_key"`
}

type TUSRequest added in v0.2.0

type TUSRequest struct {
	gorm.Model
	RequestID   uint `gorm:"uniqueIndex:idx_ipfs_req_deleted_at_request_id"`
	Request     Request
	TUSUploadID string `gorm:"type:varchar(500);uniqueIndex"`
	Completed   bool
}

type TusLock

type TusLock struct {
	gorm.Model
	LockId           string `gorm:"index:idx_lock_id,unique"`
	HolderPID        int    `gorm:"index"`
	AcquiredAt       time.Time
	ExpiresAt        time.Time
	ReleaseRequested bool
	DeletedAt        gorm.DeletedAt `gorm:"index:idx_lock_id,unique"`
}

func (*TusLock) Delete

func (t *TusLock) Delete(db *gorm.DB) error

func (*TusLock) IsReleaseRequested

func (t *TusLock) IsReleaseRequested(db *gorm.DB) (bool, error)

func (*TusLock) Released

func (t *TusLock) Released(db *gorm.DB) error

func (*TusLock) RequestRelease

func (t *TusLock) RequestRelease(db *gorm.DB) error

func (*TusLock) TryLock

func (t *TusLock) TryLock(db *gorm.DB, ctx context.Context) error

type Upload

type Upload struct {
	gorm.Model
	UserID     uint
	HashType   uint64
	Hash       mh.Multihash `gorm:"type:varbinary(64);uniqueIndex:idx_upload_hash_deleted_at"`
	CIDType    uint64       `gorm:"column:cid_type"`
	MimeType   string
	Protocol   string
	User       User
	UploaderIP string
	Size       uint64
	Metadata   datatypes.JSON
	DeletedAt  gorm.DeletedAt `gorm:"uniqueIndex:idx_upload_hash_deleted_at"`
}

type User

type User struct {
	gorm.Model
	FirstName          string
	LastName           string
	Email              string `gorm:"unique"`
	PasswordHash       string
	Role               string
	PublicKeys         []PublicKey
	Uploads            []Upload
	LastLogin          *time.Time
	LastLoginIP        string
	OTPEnabled         bool `gorm:"default:false;"`
	OTPVerified        bool `gorm:"default:false;"`
	OTPSecret          string
	OTPAuthUrl         string
	Verified           bool `gorm:"default:false;"`
	EmailVerifications []EmailVerification
	PasswordResets     []PasswordReset
}

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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