store

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdmin     = "admin"
	RoleModerator = "moderator"
	RoleUser      = "user"
)

Variables

View Source
var (
	ErrNotFound = fmt.Errorf("not found")
)

Functions

func Import

func Import(r io.Reader, s *Effects) error

Import a BSON dump to a store.

Types

type Effect

type Effect struct {
	ID            int
	CreatedAt     time.Time
	ModifiedAt    time.Time
	Parent        int
	ParentVersion int
	User          string
	Hidden        bool
	Versions      []Version
}

func Convert

func Convert(j JSONEffect) Effect

Convert a BSON struct into Effect.

func (Effect) ImageName

func (e Effect) ImageName() string

type Effects

type Effects struct {
	// contains filtered or unexported fields
}

func NewEffects

func NewEffects(db *sqlx.DB) (*Effects, error)

func (*Effects) Add

func (s *Effects) Add(
	parent int, parentVersion int, user string, version string,
) (int, error)

func (*Effects) AddEffect

func (s *Effects) AddEffect(e Effect) error

func (*Effects) AddVersion

func (s *Effects) AddVersion(id int, code string) (int, error)

func (*Effects) Effect

func (s *Effects) Effect(id int) (Effect, error)

func (*Effects) Hide

func (s *Effects) Hide(id int, hidden bool) error

func (*Effects) Page

func (s *Effects) Page(num int, size int, hidden bool) ([]Effect, error)

func (*Effects) PageSiblings added in v0.1.2

func (s *Effects) PageSiblings(num int, size int, parent int) ([]Effect, error)

type JSONDate

type JSONDate struct {
	Date int64 `json:"$date"`
}

func (JSONDate) Time

func (j JSONDate) Time() time.Time

type JSONEffect

type JSONEffect struct {
	ID            int           `json:"_id"`
	CreatedAt     JSONDate      `json:"created_at"`
	ImageURL      string        `json:"image_url"`
	ModifiedAt    JSONDate      `json:"modified_at"`
	Parent        int           `json:"parent"`
	ParentVersion int           `json:"parent_version"`
	User          string        `json:"user"`
	Hidden        bool          `json:"hidden"`
	Versions      []JSONVersion `json:"versions"`
}

JSONEffect contains the BSON dump structure.

type JSONVersion

type JSONVersion struct {
	CreatedAt JSONDate `json:"created_at"`
	Code      string   `json:"code"`
}

type Role

type Role string

type User

type User struct {
	ID        int       `db:"id"`
	Name      string    `db:"name"`
	Password  []byte    `db:"password"`
	Email     string    `db:"email"`
	Role      Role      `db:"role"`
	Active    bool      `db:"active"`
	CreatedAt time.Time `db:"created_at"`
}

type Users

type Users struct {
	// contains filtered or unexported fields
}

func NewUsers

func NewUsers(db *sqlx.DB) (*Users, error)

func (*Users) Add

func (s *Users) Add(user User) error

func (*Users) Init

func (s *Users) Init() error

func (*Users) Update

func (s *Users) Update(user User) error

func (*Users) UpdateFunc

func (s *Users) UpdateFunc(name string, f func(User) User) error

func (*Users) User

func (s *Users) User(name string) (User, error)

func (*Users) Users added in v0.1.2

func (s *Users) Users() ([]User, error)

type Version

type Version struct {
	CreatedAt time.Time
	Code      string
}

Jump to

Keyboard shortcuts

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