model

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version2 is the client version.
	Version2 = "002"
	// Version3 is the client version.
	Version3 = "003"
	// VersionLatest is the client version.
	VersionLatest = Version3
)

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"`
	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 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"`
	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 and the rendered API response.

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