Documentation ¶
Index ¶
- func Migrate(db *gorm.DB)
- func SerializeParagraphs(paragraphs []Paragraph) []common.JSON
- func SerializePosts(posts []Post) []common.JSON
- func SerializeTopics(topics []Topic) []common.JSON
- func SerializeUsers(users []User) []common.JSON
- type Follow
- type FollowedTopic
- type Paragraph
- type Post
- type PostLike
- type Topic
- type User
- func (u *User) CheckPassword(password string) error
- func (user *User) Delete()
- func (u *User) IsFollowing(following User) bool
- func (u *User) IsFollowingTopic(topic Topic) bool
- func (u *User) Read(m common.JSON)
- func (user *User) Save()
- func (u *User) Serialize() common.JSON
- func (u *User) SetPassword(newPassword string) error
- func (u *User) UnFollow(unFollowUser User) error
- func (u *User) UnFollowTopic(topic Topic) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SerializeParagraphs ¶
SerializeParagraphs serializes multiple paragraphs into JSON-format
func SerializePosts ¶
SerializePosts serializes a list posts
func SerializeTopics ¶
SerializeTopics serializes a list of topics
func SerializeUsers ¶
SerializeUsers serializes a list of users
Types ¶
type FollowedTopic ¶
FollowedTopic bypasses using many2many and makes code cleaner
type Paragraph ¶
Paragraph struct stores the post's content
func GetParagraphsRelatedToPost ¶
GetParagraphsRelatedToPost gets all the paragraphs in a post
type Post ¶
type Post struct { gorm.Model Text string Title string Likes int Description string ImageURL string User User UserID uint UUID string Paragraphs []Paragraph TopicID uint }
Post data model
func FindOnePost ¶
FindOnePost finds a post matching the given condition
func GetPostWithID ¶
GetPostWithID returns a post correspodding to given id
func GetPostsFromUser ¶
GetPostsFromUser gets all the posts related to a given user
func GetPostsRelatedToTopic ¶
GetPostsRelatedToTopic finds all posts in the topic's category
type PostLike ¶
PostLike model helps keeping track of if a user has already liked a post
func FindPostLikeModel ¶
FindPostLikeModel finds a single postLike model matching given condition
type Topic ¶
type Topic struct { gorm.Model Title string Description string UUID string URL string UserID uint User User }
Topic data model
func FindOneTopic ¶
FindOneTopic finds a single topic with the given condition
func GetAllUsersTopics ¶
GetAllUsersTopics returns all the topics created by the given user
type User ¶
User data model
func FindOneUser ¶
FindOneUser finds a single topic with the given condition
func (*User) CheckPassword ¶
CheckPassword checks if user's password is the given password
func (*User) IsFollowing ¶
IsFollowing checks for a follow model between 2 users
func (*User) IsFollowingTopic ¶
IsFollowingTopic checks if a user is following a certain topic
func (*User) SetPassword ¶
SetPassword sets a new hashed password to the user
func (*User) UnFollowTopic ¶
UnFollowTopic removes a user's following of a topic