store

package
v0.0.0-...-5d38250 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 3 Imported by: 7

Documentation

Overview

Package store provides a bebop data store interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound means the requested item is not found.
	ErrNotFound = errors.New("store: item not found")
	// ErrConflict means the operation failed because of a conflict between items.
	ErrConflict = errors.New("store: item conflict")
)

Functions

func ValidCommentContent

func ValidCommentContent(commentContent string) bool

ValidCommentContent checks if comment content is valid.

func ValidTopicTitle

func ValidTopicTitle(topicTitle string) bool

ValidTopicTitle checks if topic title is valid.

func ValidUserName

func ValidUserName(userName string) bool

ValidUserName checks if given user name is valid.

Types

type Comment

type Comment struct {
	ID        int64     `json:"id"`
	TopicID   int64     `json:"topicId"`
	AuthorID  int64     `json:"authorId"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"createdAt"`
}

Comment is a single comment on a topic.

type CommentStore

type CommentStore interface {
	New(topicID int64, authorID int64, content string) (int64, error)
	Get(id int64) (*Comment, error)
	GetByTopic(topicID int64, offset, limit int) ([]*Comment, int, error)
	SetContent(id int64, content string) error
	Delete(id int64) error
}

CommentStore is a bebop comment data store interface.

type Store

type Store interface {
	Users() UserStore
	Topics() TopicStore
	Comments() CommentStore
}

Store is a bebop data store interface.

type Topic

type Topic struct {
	ID            int64     `json:"id"`
	AuthorID      int64     `json:"authorId"`
	Title         string    `json:"title"`
	CreatedAt     time.Time `json:"createdAt"`
	LastCommentAt time.Time `json:"lastCommentAt"`
	CommentCount  int       `json:"commentCount"`
}

Topic is a discussion topic.

type TopicStore

type TopicStore interface {
	New(authorID int64, title string) (int64, error)
	Get(id int64) (*Topic, error)
	GetLatest(offset, limit int) ([]*Topic, int, error)
	SetTitle(id int64, title string) error
	Delete(id int64) error
}

TopicStore is a bebop topic data store interface.

type User

type User struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	CreatedAt   time.Time `json:"createdAt"`
	AuthService string    `json:"-"`
	AuthID      string    `json:"-"`
	Blocked     bool      `json:"-"`
	Admin       bool      `json:"-"`
	Avatar      string    `json:"avatar"`
}

User represents an authenticated user. Only public fields are marshalled to JSON by default.

type UserStore

type UserStore interface {
	New(authService string, authID string) (int64, error)
	Get(id int64) (*User, error)
	GetMany(ids []int64) (map[int64]*User, error)
	GetAdmins() ([]*User, error)
	GetByName(name string) (*User, error)
	GetByAuth(authService string, authID string) (*User, error)
	SetName(id int64, name string) error
	SetBlocked(id int64, blocked bool) error
	SetAdmin(id int64, admin bool) error
	SetAvatar(id int64, avatar string) error
}

UserStore is a bebop user data store interface.

Directories

Path Synopsis
Package mysql provides a MySQL implementation of the bebop data store interface.
Package mysql provides a MySQL implementation of the bebop data store interface.
Package postgresql provides a PostgreSQL implementation of the bebop data store interface.
Package postgresql provides a PostgreSQL implementation of the bebop data store interface.

Jump to

Keyboard shortcuts

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