dbmodel

package
v0.0.0-...-d280c18 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package dbmodel contains the binding types used by GORM to map to the database tables and rows.

Index

Constants

View Source
const (
	EntryColumnID    = "id"
	EntryColumnStart = "start"
	EntryColumnEnd   = "end"
)

Column names for Entry.

View Source
const (
	EntryFTS5ColumnRowID = "entries_idx.rowid"
	EntryFTS5ColumnName  = "entries_idx.name"
)

Column names for EntryFTS5.

View Source
const (
	EntryFieldEnd = "End"
)

Field names for Entry.

Variables

View Source
var (
	CommonFieldsColumnID = "id"
)

Fields names for CommonFields.

Functions

This section is empty.

Types

type CommonFields

type CommonFields struct {
	// ID is a unique identifier for this entry. The same ID will never be used
	// twice for a given database.
	ID uint `gorm:"primaryKey;autoIncrement;type:INTEGER PRIMARY KEY AUTOINCREMENT"`
	// CreatedAt stores when the database object was added to the database.
	//
	// It is automatically set by GORM due to its naming convention.
	CreatedAt time.Time
	// UpdatedAt stores when the database object was added to the database or
	// when it was last updated.
	//
	// It is automatically set by GORM due to its naming convention.
	UpdatedAt time.Time
}

CommonFields contains fields used by multiple other models.

type Entry

type Entry struct {
	CommonFields
	// Name of the entry.
	Name string `gorm:"not null;default:''"`
	// Start time of the entry.
	Start time.Time `gorm:"not null;default:CURRENT_TIMESTAMP;index"`
	// End time of the entry, or nil if the entry is still active.
	End *time.Time `gorm:"index"`
}

Entry is a time tracked entry stored in the database.

func (Entry) Elapsed

func (t Entry) Elapsed() time.Duration

Elapsed returns the duration of the entry. If the entry is currently active, the duration is calculated from the start to now.

type EntryFTS5

type EntryFTS5 struct {
	RowID uint   `gorm:"primaryKey;column:rowid"`
	Name  string `gorm:"not null;default:''"`
}

EntryFTS5 is used for free-text searching entries.

func (EntryFTS5) TableName

func (EntryFTS5) TableName() string

TableName overrides the table name used by GORM.

type Migration

type Migration struct {
	CommonFields
	Version MigrationVersion
}

Migration holds the latest migration revision identifier. At most one row of this object is expected to be in the database at any given time.

type MigrationVersion

type MigrationVersion int

MigrationVersion is an enumeration stating how outdated the database schema is.

const (
	// MigrationUnknown means that Dinkur was unable to evaluate the database's
	// migration status. Perhaps due to an error.
	MigrationUnknown MigrationVersion = -1
	// MigrationNeverApplied means the database has never been migrated before.
	// In other words, it's a brand new database.
	MigrationNeverApplied MigrationVersion = 0
	// MigrationUpToDate means the database does not need any further migrations
	// applied.
	MigrationUpToDate MigrationVersion = LatestMigrationVersion
)
const LatestMigrationVersion MigrationVersion = 8

LatestMigrationVersion is an integer revision identifier for what migration was last applied to the database. This is stored in the database to quickly figure out if new migrations needs to be applied.

func (MigrationVersion) String

func (s MigrationVersion) String() string

type Status

type Status struct {
	CommonFields
	AFKSince  *time.Time
	BackSince *time.Time
}

Status is used to track the user's current status, such as if they're currently AFK.

Jump to

Keyboard shortcuts

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