Documentation
¶
Index ¶
- type Category
- type CategoryRepository
- type Engagement
- type MongoCategoryRepository
- type MongoPostRepository
- func (repo MongoPostRepository) Create(ctx context.Context, authorID string) (Post, error)
- func (repo MongoPostRepository) FindAll(ctx context.Context, q PostQuery) ([]Post, error)
- func (repo MongoPostRepository) FindByID(ctx context.Context, id interface{}) (Post, error)
- func (repo MongoPostRepository) Save(ctx context.Context, id interface{}, q PostQuery) (Post, error)
- type MongoTagRepository
- type Post
- type PostQuery
- func (q PostQuery) Attachments() *[]storage.File
- func (q PostQuery) AuthorID() *string
- func (q PostQuery) Categories() *[]Category
- func (q PostQuery) Category() *Category
- func (q PostQuery) FeaturedImage() *storage.File
- func (q PostQuery) HTML() *string
- func (q PostQuery) Limit() int64
- func (q PostQuery) Markdown() *string
- func (q PostQuery) Offset() int64
- func (q PostQuery) PublishedAt() *time.Time
- func (q PostQuery) Slug() *string
- func (q PostQuery) Status() *Status
- func (q PostQuery) Tag() *Tag
- func (q PostQuery) Tags() *[]Tag
- func (q PostQuery) Title() *string
- type PostQueryBuilder
- func (qb *PostQueryBuilder) Build() PostQuery
- func (qb *PostQueryBuilder) WithAttachments(attachments []storage.File) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithAuthorID(authorID string) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithCategories(categories []Category) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithCategory(category Category) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithFeaturedImage(featuredImage storage.File) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithHTML(html string) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithLimit(limit int64) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithMarkdown(markdown string) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithOffset(offset int64) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithPublishedAt(publishedAt time.Time) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithSlug(slug string) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithStatus(status Status) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithTag(tag Tag) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithTags(tags []Tag) *PostQueryBuilder
- func (qb *PostQueryBuilder) WithTitle(title string) *PostQueryBuilder
- type PostRepository
- type Status
- type Tag
- type TagRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct { // Identifier of the category ID primitive.ObjectID `bson:"_id" json:"id" graphql:"-"` // Name of the category Name string `bson:"name" json:"name" graphql:"name"` // Valid URL string composes with name and ID Slug string `bson:"slug" json:"slug" graphql:"slug"` }
Category is a group of posts regarded as having particular shared characteristics
func (Category) MarshalJSON ¶
MarshalJSON is a custom JSON marshaling function of category entity
type CategoryRepository ¶
type CategoryRepository interface { FindAll(ctx context.Context) ([]Category, error) FindAllByIDs(ctx context.Context, ids interface{}) ([]Category, error) FindByID(ctx context.Context, id interface{}) (Category, error) }
A CategoryRepository interface
type Engagement ¶
type Engagement struct { int `bson:"-" json:"shareCount" graphql:"shareCount"` }ShareCount
Engagement represents social network engagement of the object
type MongoCategoryRepository ¶
type MongoCategoryRepository struct {
// contains filtered or unexported fields
}
MongoCategoryRepository implements CategoryRepository interface
func NewCategoryRepository ¶
func NewCategoryRepository(db mongo.Database) MongoCategoryRepository
NewCategoryRepository returns a MongoCategoryRepository instance
func (MongoCategoryRepository) FindAll ¶
func (repo MongoCategoryRepository) FindAll(ctx context.Context) ([]Category, error)
FindAll returns list of categories
func (MongoCategoryRepository) FindAllByIDs ¶
func (repo MongoCategoryRepository) FindAllByIDs(ctx context.Context, ids interface{}) ([]Category, error)
FindAllByIDs returns list of categories from list of IDs
type MongoPostRepository ¶
type MongoPostRepository struct {
// contains filtered or unexported fields
}
MongoPostRepository implements PostRepository interface
func NewPostRepository ¶
func NewPostRepository(db mongo.Database) MongoPostRepository
NewPostRepository returns a MongoPostRepository instance
func (MongoPostRepository) Create ¶
Create inserts a new empty post which belongs to the author with "Draft" status
type MongoTagRepository ¶
type MongoTagRepository struct {
// contains filtered or unexported fields
}
MongoTagRepository implements TagRepository interface
func NewTagRepository ¶
func NewTagRepository(db mongo.Database) MongoTagRepository
NewTagRepository returns a MongoTagRepository instance
func (MongoTagRepository) FindAll ¶
func (repo MongoTagRepository) FindAll(ctx context.Context) ([]Tag, error)
FindAll returns list of tags
func (MongoTagRepository) FindAllByIDs ¶
func (repo MongoTagRepository) FindAllByIDs(ctx context.Context, ids interface{}) ([]Tag, error)
FindAllByIDs returns list of tags from list of IDs
type Post ¶
type Post struct { // Identifier of the post ID primitive.ObjectID `bson:"_id" json:"id" graphql:"-"` // Title of the post Title string `bson:"title" json:"title" graphql:"title"` // Valid URL string composes with title and ID Slug string `bson:"slug" json:"slug" graphql:"slug"` // Status of the post which could be... // - PUBLISHED // - DRAFT Status Status `bson:"status" json:"status" graphql:"status"` // Original content of the post in markdown syntax Markdown string `bson:"markdown" json:"markdown" graphql:"markdown"` // Content of the post in HTML format which will be translated from markdown HTML string `bson:"html" json:"html" graphql:"html"` // Date-time that the post was published PublishedAt time.Time `bson:"publishedAt" json:"publishedAt" graphql:"publishedAt"` // Identifier of the author AuthorID string `bson:"authorId" json:"authorId" graphql:"authorId"` // List of categories (in reference to the category collection) that the post belonging to Categories []mongo.DBRef `bson:"categories" json:"-" graphql:"-"` // List of tags that the post belonging to Tags []mongo.DBRef `bson:"tags" json:"-" graphql:"-"` // A featured image to be shown in the social network as a cover image FeaturedImage mongo.DBRef `bson:"featuredImage" json:"-" graphql:"-"` // List of attachments are belonging to the post Attachments []mongo.DBRef `bson:"attachments" json:"-" graphql:"-"` // A social network engagement of the post Engagement Engagement `bson:"-" json:"engagement" graphql:"engagement"` // Date-time that the post was created CreatedAt time.Time `bson:"createdAt" json:"createdAt" graphql:"createdAt"` // Date-time that the post was updated UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt" graphql:"updatedAt"` }
Post is a piece of content in the blog platform
func (Post) MarshalJSON ¶
MarshalJSON is a custom JSON marshaling function of post entity
type PostQuery ¶
type PostQuery struct {
// contains filtered or unexported fields
}
PostQuery uses as medium for communicating between repository and data-access object (DAO)
func (PostQuery) Attachments ¶
Attachments returns list of files object
func (PostQuery) Categories ¶
Categories returns list of categories
func (PostQuery) FeaturedImage ¶
FeaturedImage returns file object
func (PostQuery) PublishedAt ¶
PublishedAt returns date-time value
type PostQueryBuilder ¶
type PostQueryBuilder struct {
// contains filtered or unexported fields
}
PostQueryBuilder a post object specific query builder
func NewPostQueryBuilder ¶
func NewPostQueryBuilder() *PostQueryBuilder
NewPostQueryBuilder returns a query builder for building post query object
func (*PostQueryBuilder) Build ¶
func (qb *PostQueryBuilder) Build() PostQuery
Build returns a post query object
func (*PostQueryBuilder) WithAttachments ¶
func (qb *PostQueryBuilder) WithAttachments(attachments []storage.File) *PostQueryBuilder
WithAttachments allows to set list of attachments to the post query object
func (*PostQueryBuilder) WithAuthorID ¶
func (qb *PostQueryBuilder) WithAuthorID(authorID string) *PostQueryBuilder
WithAuthorID allows to set an author ID to the post query object
func (*PostQueryBuilder) WithCategories ¶
func (qb *PostQueryBuilder) WithCategories(categories []Category) *PostQueryBuilder
WithCategories allows to set list of categories to the post query object
func (*PostQueryBuilder) WithCategory ¶
func (qb *PostQueryBuilder) WithCategory(category Category) *PostQueryBuilder
WithCategory allows to set category to the post query object
func (*PostQueryBuilder) WithFeaturedImage ¶
func (qb *PostQueryBuilder) WithFeaturedImage(featuredImage storage.File) *PostQueryBuilder
WithFeaturedImage allows to set featured image to the post query object
func (*PostQueryBuilder) WithHTML ¶
func (qb *PostQueryBuilder) WithHTML(html string) *PostQueryBuilder
WithHTML allows to set HTML to the post query object
func (*PostQueryBuilder) WithLimit ¶
func (qb *PostQueryBuilder) WithLimit(limit int64) *PostQueryBuilder
WithLimit allows to set limit the post query object
func (*PostQueryBuilder) WithMarkdown ¶
func (qb *PostQueryBuilder) WithMarkdown(markdown string) *PostQueryBuilder
WithMarkdown allows to set markdown to the post query object
func (*PostQueryBuilder) WithOffset ¶
func (qb *PostQueryBuilder) WithOffset(offset int64) *PostQueryBuilder
WithOffset allows to set offset to the post query object
func (*PostQueryBuilder) WithPublishedAt ¶
func (qb *PostQueryBuilder) WithPublishedAt(publishedAt time.Time) *PostQueryBuilder
WithPublishedAt allows to set a date-time which the post was published
func (*PostQueryBuilder) WithSlug ¶
func (qb *PostQueryBuilder) WithSlug(slug string) *PostQueryBuilder
WithSlug allows to set slug to the post query object
func (*PostQueryBuilder) WithStatus ¶
func (qb *PostQueryBuilder) WithStatus(status Status) *PostQueryBuilder
WithStatus allows to set status to the post query object
func (*PostQueryBuilder) WithTag ¶
func (qb *PostQueryBuilder) WithTag(tag Tag) *PostQueryBuilder
WithTag allows to set tag to the post query object
func (*PostQueryBuilder) WithTags ¶
func (qb *PostQueryBuilder) WithTags(tags []Tag) *PostQueryBuilder
WithTags allows to set list of tags to the post query object
func (*PostQueryBuilder) WithTitle ¶
func (qb *PostQueryBuilder) WithTitle(title string) *PostQueryBuilder
WithTitle allows to set title to the post query object
type PostRepository ¶
type PostRepository interface { Create(ctx context.Context, authorID string) (Post, error) FindAll(ctx context.Context, q PostQuery) ([]Post, error) FindByID(ctx context.Context, id interface{}) (Post, error) Save(ctx context.Context, id interface{}, q PostQuery) (Post, error) }
A PostRepository interface
type Status ¶
type Status string
Status for indicating the access level of the post
const StatusDraft Status = "DRAFT"
StatusDraft indicates that the post is private, can only be accessed by the author
const StatusPublished Status = "PUBLISHED"
StatusPublished indicates that post is public, accessible to everyone
func (Status) IsPublished ¶
IsPublished returns "true" if status is Published
type Tag ¶
type Tag struct { // Identifier of the tag ID primitive.ObjectID `bson:"_id" json:"id" graphql:"-"` // Name of the tag Name string `bson:"name" json:"name" graphql:"name"` // Valid URL string composes with name and ID Slug string `bson:"slug" json:"slug" graphql:"slug"` }
Tag is a label attached to the post for the purpose of identification
func (Tag) MarshalJSON ¶
MarshalJSON is a custom JSON marshaling function of tag entity