ucdb

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 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 BaseModel

type BaseModel struct {
	ID uuid.UUID `db:"id" json:"id" yaml:"id"`

	Created time.Time `db:"created" json:"created" yaml:"created"`
	Updated time.Time `db:"updated" json:"updated" yaml:"updated"`

	Deleted time.Time `db:"deleted" json:"deleted" yaml:"deleted"`
}

BaseModel underlies (almost) all of our models

func NewBase

func NewBase() BaseModel

NewBase initializes a new UCBase

func NewBaseWithID

func NewBaseWithID(id uuid.UUID) BaseModel

NewBaseWithID initializes a new BaseModel with a specific ID

func (BaseModel) Alive

func (b BaseModel) Alive() bool

Alive returns true if the object is "alive" and false if it's been deleted

func (BaseModel) GetCreated added in v0.3.0

func (b BaseModel) GetCreated() time.Time

GetCreated is part of the BaseModelable interface

func (BaseModel) GetDeleted added in v0.3.0

func (b BaseModel) GetDeleted() time.Time

GetDeleted is part of the BaseModelable interface

func (BaseModel) GetID added in v0.3.0

func (b BaseModel) GetID() uuid.UUID

GetID is part of the BaseModelable interface

func (BaseModel) GetUpdated added in v0.3.0

func (b BaseModel) GetUpdated() time.Time

GetUpdated is part of the BaseModelable interface

func (BaseModel) Validate

func (b BaseModel) Validate() error

Validate implements Validateable

type BaseModelable added in v0.3.0

type BaseModelable interface {
	GetCreated() time.Time
	GetDeleted() time.Time
	GetID() uuid.UUID
	GetUpdated() time.Time
}

BaseModelable is an interface that all BaseModel instances and ancestors support Golang generics do not currently support accessing a struct field for a generic type within a method, so this interface was created to enable us to have generic methods that take any model object that is derived from the BaseModel struct, and be able to access any of the fields in BaseModel from within the generic method.

type SystemAttributeBaseModel added in v0.7.2

type SystemAttributeBaseModel struct {
	BaseModel

	// note: the "description" tag is for OpenAPI spec generation, because we
	// use DB model structs as client models in a few places where it's not
	// worth maintaining separate DB and client models
	IsSystem bool `` /* 170-byte string literal not displayed */
}

SystemAttributeBaseModel is for resource types where we may have system resources that clients should not be able to update or delete

func MarkAsSystem added in v0.7.2

MarkAsSystem returns a copy of the given model with IsSystem set to true

func NewSystemAttributeBase added in v0.7.2

func NewSystemAttributeBase() SystemAttributeBaseModel

NewSystemAttributeBase initializes a new SystemAttributeBaseModel

func NewSystemAttributeBaseWithID added in v0.7.2

func NewSystemAttributeBaseWithID(id uuid.UUID) SystemAttributeBaseModel

NewSystemAttributeBaseWithID initializes a new SystemAttributeBaseModel with a specific ID

type UserBaseModel

type UserBaseModel struct {
	BaseModel

	UserID uuid.UUID `db:"user_id" json:"user_id" yaml:"user_id"`
}

UserBaseModel is a user-related underlying model for many of our models eg. in IDP

func NewUserBase

func NewUserBase(userID uuid.UUID) UserBaseModel

NewUserBase initializes a new user base model

func (UserBaseModel) Validate

func (u UserBaseModel) Validate() error

Validate implements Validateable

type VersionBaseModel added in v0.3.0

type VersionBaseModel struct {
	BaseModel

	// we use _version here to indicate that it's system-managed (as distinct from eg. versioned Access Policies)
	Version int `db:"_version" json:"version"`
}

VersionBaseModel supports safe concurrent updates with version checks (only save if you have extant version)

func NewVersionBase added in v0.3.0

func NewVersionBase() VersionBaseModel

NewVersionBase initializes a new VersionBaseModel

func NewVersionBaseWithID added in v0.3.0

func NewVersionBaseWithID(id uuid.UUID) VersionBaseModel

NewVersionBaseWithID initializes a new VersionBaseModel with a specific ID

Jump to

Keyboard shortcuts

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