Documentation
¶
Index ¶
- type Author
- type Comment
- func (c *Comment) Content() string
- func (c *Comment) ContentMarkdown() string
- func (c *Comment) Date() time.Time
- func (c *Comment) Destroy() error
- func (c *Comment) DownVote() int64
- func (c *Comment) Id() int64
- func (c *Comment) Post() (*Post, error)
- func (c *Comment) Save() error
- func (c *Comment) SetContent(content string)
- func (c *Comment) SetDate(date time.Time)
- func (c *Comment) SetDownVote(count int64)
- func (c *Comment) SetUpVote(count int64)
- func (c *Comment) UpVote() int64
- func (c *Comment) User() (*User, error)
- type DBConnection
- func (conn *DBConnection) DeleteConnection()
- func (conn *DBConnection) FindAllAuthors() ([]Author, error)
- func (conn *DBConnection) FindAllComments() ([]Comment, error)
- func (conn *DBConnection) FindAllLabels() ([]Label, error)
- func (conn *DBConnection) FindAllPosts() ([]Post, error)
- func (conn *DBConnection) FindAllUsers() ([]User, error)
- func (conn *DBConnection) FindAuthorById(id int64) (*Author, error)
- func (conn *DBConnection) FindCommentById(id int64) (*Comment, error)
- func (conn *DBConnection) FindLabelById(id int64) (*Label, error)
- func (conn *DBConnection) FindPostById(id int64) (*Post, error)
- func (conn *DBConnection) FindUserById(id int64) (*User, error)
- func (conn *DBConnection) FindUserByOAuthId(oauthId string) (*User, error)
- func (conn *DBConnection) NewAuthor(user *User) *Author
- func (conn *DBConnection) NewComment(userId int64, postId int64, content string, date time.Time) *Comment
- func (conn *DBConnection) NewPost(author *Author, title string, content string, imageURL string, date time.Time) *Post
- func (conn *DBConnection) NewUser(username string, regDate time.Time, timezone int, oauthId string, ...) *User
- type DBVendor
- type Label
- type Post
- func (p *Post) AddLabel(name string) (Label, error)
- func (p *Post) Author() *Author
- func (p *Post) Comments() ([]Comment, error)
- func (p *Post) Content() string
- func (p *Post) ContentMarkdown() string
- func (p *Post) Date() time.Time
- func (p *Post) Destroy() error
- func (p *Post) Id() int64
- func (p *Post) ImageURL() string
- func (p *Post) Labels() ([]Label, error)
- func (p *Post) RemoveLabel(label *Label) error
- func (p *Post) Save() error
- func (p *Post) SetContent(content string)
- func (p *Post) SetDate(time time.Time)
- func (p *Post) SetImageURL(imageURL string)
- func (p *Post) SetTitle(title string)
- func (p *Post) Title() string
- func (p *Post) Update() error
- type Postgreser
- type User
- func (u *User) AccessToken() string
- func (u *User) Comments() ([]Comment, error)
- func (u User) Destroy() error
- func (u *User) Email() string
- func (u *User) Id() int64
- func (u *User) OauthId() string
- func (u *User) RefreshToken() string
- func (u *User) RegistrationDate() time.Time
- func (u *User) Save() error
- func (u *User) SetEmail(email string)
- func (u *User) SetOauthId(id string)
- func (u *User) SetRegistrationDate(date time.Time)
- func (u *User) SetTimezone(zone int)
- func (u *User) SetToken(access, refresh string)
- func (u *User) SetUsername(username string)
- func (u *User) Timezone() int
- func (u *User) Username() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶
type Author struct {
// contains filtered or unexported fields
}
Represents an author of the blog
func (*Author) Destroy ¶
Removes the user from the author table. The user attached to the author is not destroyed.
type Comment ¶
type Comment struct {
// contains filtered or unexported fields
}
Represents a comment on a post. Comments are made by Users.
func (*Comment) ContentMarkdown ¶
func (*Comment) Destroy ¶
Deletes the comment from the database. Returns an error if something went wrong.
func (*Comment) Save ¶
Saves the post (or update it if it already exists) to the database. Returns an error if something went wrong.
func (*Comment) SetContent ¶
func (*Comment) SetDownVote ¶
type DBConnection ¶
type DBConnection struct {
// contains filtered or unexported fields
}
Keeps all info required to save stuff on a database
func NewConnection ¶
func NewConnection(modelaser DBVendor) (*DBConnection, error)
Creates a connection with the given DBVendor argument. You can then use that connection to create objects on the DB and then use those objects to update the DB.
func (*DBConnection) DeleteConnection ¶
func (conn *DBConnection) DeleteConnection()
Drops all the tables held in the database to which this object is linked. WARNING: all your data will be lost. You should only do that in a testing environment.
func (*DBConnection) FindAllAuthors ¶
func (conn *DBConnection) FindAllAuthors() ([]Author, error)
Finds all the Authors known to this blog. Returns an empty slice and an error stating no rows matched the request if no authors are known to this blog.
func (*DBConnection) FindAllComments ¶
func (conn *DBConnection) FindAllComments() ([]Comment, error)
Finds all the comments in the database. Returns an empty slice with an error if not comments were found.
func (*DBConnection) FindAllLabels ¶
func (conn *DBConnection) FindAllLabels() ([]Label, error)
Finds all the labels in the database
func (*DBConnection) FindAllPosts ¶
func (conn *DBConnection) FindAllPosts() ([]Post, error)
Finds all the posts in the database
func (*DBConnection) FindAllUsers ¶
func (conn *DBConnection) FindAllUsers() ([]User, error)
Finds all the users in the database
func (*DBConnection) FindAuthorById ¶
func (conn *DBConnection) FindAuthorById(id int64) (*Author, error)
Returns an author given its id. If the id is not known to the blog a nil value is returned with an error.
func (*DBConnection) FindCommentById ¶
func (conn *DBConnection) FindCommentById(id int64) (*Comment, error)
Finds a comment that matches the given id. Returns nil and an error if the id didn't match any comment.
func (*DBConnection) FindLabelById ¶
func (conn *DBConnection) FindLabelById(id int64) (*Label, error)
func (*DBConnection) FindPostById ¶
func (conn *DBConnection) FindPostById(id int64) (*Post, error)
Finds a post that matches the given id
func (*DBConnection) FindUserById ¶
func (conn *DBConnection) FindUserById(id int64) (*User, error)
Finds a user that matches the given id
func (*DBConnection) FindUserByOAuthId ¶
func (conn *DBConnection) FindUserByOAuthId(oauthId string) (*User, error)
Finds a user that matches the given id
func (*DBConnection) NewAuthor ¶
func (conn *DBConnection) NewAuthor(user *User) *Author
Creates an author. The Author is NOT saved. To save it, you must call the save method on the returned Author.
func (*DBConnection) NewComment ¶
func (conn *DBConnection) NewComment(userId int64, postId int64, content string, date time.Time) *Comment
Creates a new Comment attached to the database. It is NOT saved in the database, you must call "Save" on this comment to have it persisted
type DBVendor ¶
type DBVendor interface { // not exported because only used within package Name() string Driver() string }
Interface to abstract between different drivers (SQLite or Postgres)
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Represents a label from the blog
func (*Label) Destroy ¶
Deletes the label from the database. If any post is referencing this label, they will not do so anymore
type Post ¶
type Post struct {
// contains filtered or unexported fields
}
Represents a post in the blog
func (*Post) ContentMarkdown ¶
func (*Post) RemoveLabel ¶
Removes a label from a post. If the post if the only post referring to that label, it will delete the label altogether. Otherwise it will remove the label only for that post, leaving other posts unaffected
func (*Post) SetContent ¶
func (*Post) SetImageURL ¶
type Postgreser ¶
type Postgreser struct {
// contains filtered or unexported fields
}
A connection to a PostgreSQL model.
func NewPostgreser ¶
func NewPostgreser(modelurl string) Postgreser
Prepares a Postgreser for use as DBVendor
func (Postgreser) DateField ¶
func (model Postgreser) DateField() string
func (Postgreser) Driver ¶
func (model Postgreser) Driver() string
The name of the driver for the PostgreSQL driver
func (Postgreser) IncrementPrimaryKey ¶
func (model Postgreser) IncrementPrimaryKey() string
type User ¶
type User struct {
// contains filtered or unexported fields
}
Represents a User of the blog