Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileModel ¶
type FileModel struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` // File ID
Name string `gorm:"not null;uniqueIndex:idx_file_parent_name" json:"name"` // File name
Path string `gorm:"not null;unique" json:"path"` // File path
ContentType string `gorm:"not null" json:"content_type"` // MIME type (e.g., image/png, application/pdf)
Size int64 `gorm:"not null" json:"size"` // File size in bytes
ParentID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:idx_file_parent_name" json:"parent_id"` // Foreign key to FolderModel
Hash string `gorm:"not null;index" json:"hash"` // Hash of the file for integrity checks and uniqueness
Data []byte `gorm:"-" json:"data"` // File data
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
type FolderModel ¶
type FolderModel struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` // Unique identifier for the file
UserID string `gorm:"not null;uniqueIndex:idx_folder_user_parent_name" json:"user_id"` // ID of the user who owns the bucket
ParentID *uuid.UUID `gorm:"type:uuid;uniqueIndex:idx_folder_user_parent_name" json:"parent_id"` // Foreign key to FolderModel
Name string `gorm:"not null;uniqueIndex:idx_folder_user_parent_name" json:"name"` // Folder name
Description string `gorm:"type:text" json:"description"` // Optional description of the bucket
Path string `gorm:"not null;unique" json:"path"` // File path
Folders []FolderModel `gorm:"foreignKey:ParentID;constraint:OnDelete:CASCADE" json:"folders"` // Establish one-to-many relationship with FolderModel
Files []FileModel `gorm:"foreignKey:ParentID;constraint:OnDelete:CASCADE" json:"files"` // Establish one-to-many relationship with FileModel
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
func (*FolderModel) BeforeCreate ¶
func (folder *FolderModel) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate hook for FolderModel to add a prefixed UUID
type MigrationBackend ¶ added in v1.2.0
type MigrationBackend string
const ( MigrationBackendLocal MigrationBackend = "local" MigrationBackendS3 MigrationBackend = "s3" )
type MigrationModel ¶ added in v1.2.0
type MigrationModel struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
FileID uuid.UUID `gorm:"type:uuid" json:"file_id"`
Backend MigrationBackend `gorm:"backend" json:"backend"`
ObjectKey string `gorm:"object_key" json:"object_key"`
Size int64 `gorm:"size" json:"size"`
ChecksumSHA256 string `gorm:"checksum_sha256" json:"checksum_sha256"`
Status MigrationStatus `gorm:"status" json:"status"`
Version int `gorm:"version" json:"version"`
CreatedAt time.Time `gorm:"created_at" json:"created_at"`
UpdatedAt time.Time `gorm:"updated_at" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
func (*MigrationModel) BeforeCreate ¶ added in v1.2.0
func (migration *MigrationModel) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate hook for MigrationModel to add a prefixed UUID
type MigrationStatus ¶ added in v1.2.0
type MigrationStatus string
const ( MigrationStatusQueued MigrationStatus = "queued" MigrationStatusUploading MigrationStatus = "uploading" MigrationStatusVerifying MigrationStatus = "verifying" MigrationStatusCommitted MigrationStatus = "committed" MigrationStatusFailed MigrationStatus = "failed" )
Click to show internal directories.
Click to hide internal directories.