example

package
v0.0.0-...-a565181 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

A sample code to describe how to use the boltsec and use json.Unmarshal to convert the []byte values into Article object

Index

Constants

This section is empty.

Variables

View Source
var Logger = log.New(os.Stdout, "[ArticleManager] ", log.LstdFlags)

Functions

func InitRand

func InitRand()

func RandStringRunes

func RandStringRunes(n int) string

Types

type Article

type Article struct {
	ID            string    `json:"id"`
	Name          string    `json:"title"`
	Tags          []string  `json:"tags"`
	Content       string    `json:"content"`
	ContentToMark string    `json:"contentToMark"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
}

type ArticleManager

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

func NewArticleManager

func NewArticleManager(name, fullpath, secret string) (*ArticleManager, error)

func (*ArticleManager) Delete

func (am *ArticleManager) Delete(id string) error

func (*ArticleManager) GetByID

func (am *ArticleManager) GetByID(id string) (result *Article, err error)

func (*ArticleManager) NewArticle

func (am *ArticleManager) NewArticle(name, content, contentToMark string, tags []string) (*Article, error)

func (*ArticleManager) Save

func (am *ArticleManager) Save(record *Article) error

func (*ArticleManager) Seek

func (am *ArticleManager) Seek() (results []*Article, err error)

func (*ArticleManager) Update

func (am *ArticleManager) Update(record *Article) error

type ArticleSearch

type ArticleSearch struct {
	Keywords string `json:"keywords"`
}

type ArticleSortByUpdateTime

type ArticleSortByUpdateTime []*Article

func (ArticleSortByUpdateTime) Len

func (a ArticleSortByUpdateTime) Len() int

func (ArticleSortByUpdateTime) Less

func (a ArticleSortByUpdateTime) Less(i, j int) bool

func (ArticleSortByUpdateTime) Swap

func (a ArticleSortByUpdateTime) Swap(i, j int)

Jump to

Keyboard shortcuts

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