database

package
v0.0.0-...-ffeae0b Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// Incremented every time the format changes so that migrations may be done.
	Version databaseVersion

	// A map of record id to record.
	Records map[UniqueId]*Record
}

type Field

type Field struct {
	// The human-readable title of this field.
	Title string

	// Whether this field is for use by the system, meaning primarily that it
	// can't be removed or modified by the user in any way.
	IsSystemField bool

	// The data this field contains, or the empty string if it contains no data.
	Data string

	// A slice of validation functions to use on this field. Each function should
	// take a pointer to a single field, then return whether the field is
	// considered "valid" or not.
	Validators []func(*Field) bool
}

A single field within a record. Certain fields are special and cannot be modified.

type Record

type Record struct {
	Id        UniqueId
	CreatedAt time.Time

	// The dates this item existed during. If it's the first version of the
	// record, `ValidFrom` will be identical to `CreatedAt`. If it's the current
	// version of the record, `ValidTo` will be `nil`.
	ValidFrom time.Time
	ValidTo   time.Time

	// The title of this record.
	Title string

	// An array of GMail-like string tags, in sorted order, de-duplicated.
	Tags []string

	// The fields used by this record.
	Data []*Field
}

type UniqueId

type UniqueId [16]byte

A unique id is just 128 random bytes.

func NewUniqueId

func NewUniqueId() (UniqueId, error)

func (*UniqueId) String

func (id *UniqueId) String() string

Jump to

Keyboard shortcuts

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