Documentation
¶
Overview ¶
Package store provides a forum 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 ¶
ValidCommentContent checks if comment content is valid.
func ValidTopicTitle ¶
ValidTopicTitle checks if topic title is valid.
func ValidUserName ¶
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"`
RequestHash string `json:"requestHash"`
}
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 forum comment data store interface.
type Store ¶
type Store interface {
Users() UserStore
Topics() TopicStore
Comments() CommentStore
}
Store is a forum 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"`
RequestHash string `json:"requestHash"`
}
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 forum 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 forum user data store interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package covenantsql provides a CovenantSQL implementation of the forum data store interface.
|
Package covenantsql provides a CovenantSQL implementation of the forum data store interface. |
Click to show internal directories.
Click to hide internal directories.