models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

The `models` module provides core database types like User.

These structures should stay pretty much the same, so if you need additional fields, just extend the struct and build the object with joins.

Please don't alter tables; add a relationship with an ORM to another table, or use an adjacent table with joins: “select * from users join cldata.users on public.users.id = cldata.users.uid where id = $(uuidgen);“

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthTokenInvalid = errors.New("auth token issued or read from database incorrectly")
	ErrAuthTokenExpired = errors.New("auth token expired or revoked")
)

Unstable; these errors will probably move elsewhere.

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	bun.BaseModel `bun:"table:auth_tokens"`
	Token         string `bun:",pk"`
	UID           string
	User          *User `bun:"-"`
	Revoked       bool
	IssuedAt      time.Time
}

func (AuthToken) Validate

func (at AuthToken) Validate() error

type User

type User struct {
	bun.BaseModel `bun:"table:users"`
	ID            string `json:"id" bun:",pk,type:uuid"`
	Username      string `json:"username"`

	GivenName  string `json:"given_name"`
	FamilyName string `json:"family_name"`
	MiddleName string `json:"middle_name,omitempty"`
	NameSuffix string `json:"name_suffix,omitempty"`
	Email      string `json:"email,omitempty"`

	LastLogin time.Time `json:"last_login"` // omitempty doesn't work for literal null
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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