models

package
v0.0.0-...-ef34e04 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() error

Connect starts a connection pool with the database

Types

type Content

type Content struct {
	Path        string      `db:"path" yaml:"-"`
	Title       string      `db:"title"`
	Body        string      `db:"body" yaml:"-"`
	Date        time.Time   `db:"date" yaml:"date"`
	PublishDate time.Time   `db:"publishdate" yaml:"publishdate,omitempty"`
	ExpiryDate  *time.Time  `db:"expirydate" yaml:"expirydate,omitempty"`
	LastMod     time.Time   `db:"lastmod" yaml:"lastmod,omitempty"`
	Author      string      `db:"author" yaml:"author,omitempty"`
	Tags        []string    `db:"tags" yaml:",omitempty"`
	Resources   []*Resource `yaml:"resources,omitempty"`
	Draft       bool        `db:"draft" yaml:"draft,omitempty"`
}

Content represents a content from database

func ReadAllContents

func ReadAllContents() ([]*Content, error)

ReadAllContents loads all contents from database

func (*Content) Size

func (c *Content) Size() uint64

Size calculates size in bytes of this content in markdown format

func (*Content) String

func (c *Content) String() string

type Resource

type Resource struct {
	Src     string            `db:"src" yaml:"src"`
	Parent  string            `db:"parent" yaml:"-"`
	Title   *string           `db:"title" yaml:"title,omitempty"`
	Params  map[string]string `db:"params" yaml:"params,omitempty"`
	Bs      []byte            `db:"bs" yaml:"-"`
	Length  uint64            `db:"length" yaml:"-"`
	LastMod time.Time         `db:"lastmod" yaml:"-"`
}

Resource represents a file attached to a Content

func ReadAllResources

func ReadAllResources() ([]*Resource, error)

ReadAllResources loads all resources from database

func (*Resource) Load

func (r *Resource) Load() error

Load loads bytes from an only resource on database

func (*Resource) Size

func (r *Resource) Size() uint64

Size returns size in bytes for this resource

Jump to

Keyboard shortcuts

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