model

package
v0.0.0-...-36feab7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	// contains filtered or unexported fields
}

Post is a domain model for the posts.

func NewPost

func NewPost(userID int, mediaID *int, caption string) (*Post, error)

NewPost returns a new instance of the Post domain model, providing the given data is valid. This function assumes userID is a valid user id.

func PostFromDao

func PostFromDao(d *dao.Post) *Post

PostFromDao returns a new instance of Post, populated with the data from the data access object. This should only be used by the PostRepository, to instantiate new domain models.

func (*Post) CanLike

func (p *Post) CanLike() error

CanLike determines if a user can like this post or not. An error is returned, if the user cannot like it.

func (*Post) CanUnlike

func (p *Post) CanUnlike() error

CanUnlike determines if a user can unlike this post or not. An error is returned, if the user cannot unlike it.

func (*Post) Dao

func (p *Post) Dao() *dao.Post

Dao returns a data access object populated with the post's data.

func (*Post) ID

func (p *Post) ID() int

ID returns the post's id.

func (*Post) ReferenceID

func (p *Post) ReferenceID() string

ReferenceID returns the post's reference id.

func (*Post) SetID

func (p *Post) SetID(id int)

SetID sets the id of the post.

func (*Post) SetReferenceID

func (p *Post) SetReferenceID(referenceID string)

SetReferenceID sets the reference id of the post.

Jump to

Keyboard shortcuts

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