Documentation ¶
Index ¶
- func CreateComment(comment Comment) error
- func CreatePost(post Post) error
- func CreateSub(sub Sub) error
- func CreateUser(user User) error
- func CreateVote(vote Vote) error
- func DeleteComment(id uint64) error
- func DeletePost(id uint64) error
- func DeleteSub(id uint64) error
- func InitDb()
- func Slugify(name string) string
- func UpdateComment(comment Comment) error
- func UpdatePost(post Post) error
- func UpdateSub(sub Sub) error
- func UpdateVote(vote Vote) error
- type Comment
- type Comments
- type Post
- type Posts
- type Score
- type Sub
- type Subs
- type User
- type Users
- type Vote
- type Votes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateComment ¶
CreateComment executes the query that creates a comment
func CreatePost ¶
CreatePost executes the query that creates a post
func CreateSub ¶
TODO: make create take and return a struct CreateSub executes the query that creates a sub
func CreateUser ¶
TODO: make create take and return a struct CreateUser executes the query that creates a user
func CreateVote ¶
CreateVote executes a query that creates a vote, it assures the value is -1, 0, or 1
func DeleteComment ¶
DeleteComment executes the query that deletes a comment
func DeletePost ¶
DeletePost executes the query to delete a post by id
func UpdateComment ¶
UpdateComment executes the query that updates a comment
func UpdatePost ¶
UpdatePost executes the query that updates a post
func UpdateVote ¶
UpdateVote executes a query that updates a vote, it assures the value is -1, 0, or 1
Types ¶
type Comment ¶
type Comment struct { ID uint64 `db:"id" json:"id"` UserID uint64 `db:"user_id" json:"userId"` CommentableID uint64 `db:"commentable_id" json:"commentableId"` CommentableType string `db:"commentable_type" json:"commentableType"` Body string `db:"body" json:"body"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` }
Comment is a struct
func GetComment ¶
GetComment executes the query that gets a comment
type Post ¶
type Post struct { ID uint64 `db:"id" json:"id"` UserID uint64 `db:"user_id" json:"userId"` SubID uint64 `db:"sub_id" json:"subId"` Title string `db:"title" json:"title"` Body string `db:"body" json:"body"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` Score Score `json:"score"` }
Post is a struct
type Sub ¶
type Sub struct { ID uint64 `db:"id" json:"id"` Slug string `db:"slug" json:"slug"` Name string `db:"name" json:"name"` Description string `db:"description" json:"description"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` }
Sub is a struct
func GetSubByID ¶
GetSub executes the query that gets a sub by id
func GetSubBySlug ¶
GetSub executes the query that gets a sub by id
type User ¶
type User struct { ID uint64 `db:"id" json:"id"` Username string `db:"username" json:"username"` Passphrase string `db:"passphrase" json:"passphrase"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` }
Comment is a struct
func GetUserByUsername ¶
GetUserByUsername executes the query that gets a user by username
type Vote ¶
type Vote struct { ID uint64 `db:"id" json:"id"` UserID uint64 `db:"user_id" json:"userId"` VotableID uint64 `db:"votable_id" json:"votableId"` VotableType string `db:"votable_type" json:"votableType"` Value int `db:"value" json:"value"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` }
Vote is a struct
func GetVoteForUser ¶
GetVoteForUser executes a query that gets a vote for a particular user on the particular votable