model

package
v0.6.2-0...-436338d Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID        string     `json:"uuid"       msgpack:"id"         storm:"id"`
	CreatedAt *time.Time `json:"created_at" msgpack:"created_at" storm:"index"`
	UpdatedAt *time.Time `json:"updated_at" msgpack:"updated_at" storm:"index"`
}

A Base contains the default model fields.

func (*Base) GetCreatedAt

func (m *Base) GetCreatedAt() *time.Time

GetCreatedAt returns the model's creation date.

func (*Base) GetID

func (m *Base) GetID() string

GetID returns the model's ID.

func (*Base) GetUpdatedAt

func (m *Base) GetUpdatedAt() *time.Time

GetUpdatedAt returns the model's last update date.

func (*Base) SetCreatedAt

func (m *Base) SetCreatedAt(t time.Time)

SetCreatedAt defines the model's creation date.

func (*Base) SetID

func (m *Base) SetID(id string)

SetID defines the model's ID.

func (*Base) SetUpdatedAt

func (m *Base) SetUpdatedAt(t time.Time)

SetUpdatedAt defines the model's last update date.

type Item

type Item struct {
	Base `msgpack:",inline" storm:"inline"`

	UserID           string `json:"user_uuid"    msgpack:"user_id"                 storm:"index"`
	ItemsKeyID       string `json:"items_key_id" msgpack:"items_key_id,omitempty"`
	Content          string `json:"content"      msgpack:"content"`
	ContentType      string `json:"content_type" msgpack:"content_type"            storm:"index"`
	EncryptedItemKey string `json:"enc_item_key" msgpack:"enc_item_key"`
	Deleted          bool   `json:"deleted"      msgpack:"deleted"                 storm:"index"`
}

A Item represents a database record and the rendered API response.

type Model

type Model interface {
	// GetID returns the model's ID.
	GetID() string
	// SetID defines the model's ID.
	SetID(string)
	// GetCreatedAt returns the model's creation date.
	GetCreatedAt() *time.Time
	// SetCreatedAt defines the model's creation date.
	SetCreatedAt(time.Time)
	// GetUpdatedAt returns the model's last update date.
	GetUpdatedAt() *time.Time
	// SetUpdatedAt defines the model's last update date.
	SetUpdatedAt(time.Time)
}

A Model defines an object that can be stored in database.

type Session

type Session struct {
	Base `msgpack:",inline" storm:"inline"`

	ExpireAt     time.Time `msgpack:"expire_at"`
	UserID       string    `msgpack:"user_id"       storm:"index"`
	UserAgent    string    `msgpack:"user_agent"`
	APIVersion   string    `msgpack:"api_version"`
	AccessToken  string    `msgpack:"access_token"  storm:"index"`
	RefreshToken string    `msgpack:"refresh_token"`

	// Custom fields
	Current bool `msgpack:"-"`
}

A Session represents a database record.

type User

type User struct {
	Base `msgpack:",inline" storm:"inline"`

	// Standardfile fields
	Email         string `msgpack:"email"    storm:"unique"`
	Password      string `msgpack:"password,omitempty"`
	PasswordCost  int    `msgpack:"pw_cost,omitempty"`
	PasswordNonce string `msgpack:"pw_nonce,omitempty"`
	PasswordAuth  string `msgpack:"pw_auth,omitempty"`
	Version       string `msgpack:"version"`

	// V2 flields compatibility
	PasswordSalt string `msgpack:"pw_salt,omitempty"`

	// Custom fields
	PasswordUpdatedAt int64 `msgpack:"password_updated_at"`
}

A User represents a database record.

func NewUser

func NewUser() *User

NewUser returns a new user with default params.

Jump to

Keyboard shortcuts

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