model

package
v0.0.0-...-e63752d Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalTimestamp

func MarshalTimestamp(t time.Time) graphql.Marshaler

Function for converting a time-object to an RFC3339-String with GraphQL. Returns the corresponding marshaller to perform this task.

func UnmarshalTimestamp

func UnmarshalTimestamp(v interface{}) (time.Time, error)

Function for converting a RFC3339 Time-String into an time-object. Used by GraphQL. Returns a Time-Object representing the Time-String.

Types

type Article

type Article struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Content     string    `json:"content"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

Product-Entity which is used to store a product object into the database

type CreateArticle

type CreateArticle struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Content     string `json:"content"`
}

func (*CreateArticle) IsValid

func (creationRequest *CreateArticle) IsValid() bool

Returns if the UpdateArticle-Object is valid Could be improved by returning a list of validation errors instead of just a boolean.

func (*CreateArticle) TransformToArticle

func (creationRequest *CreateArticle) TransformToArticle() (*Article, error)

Transforms a CreateArticle-Request into an Article-Object. Returns the new Article-Object or an error, if the CreateArticle-Request is not valid.

type UpdateArticle

type UpdateArticle struct {
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	Content     *string `json:"content,omitempty"`
}

func (*UpdateArticle) IsValid

func (update *UpdateArticle) IsValid() bool

Returns if the UpdateArticle-Object is valid Could be improved by returning a list of validation errors instead of just a boolean.

func (*UpdateArticle) MergeChanges

func (update *UpdateArticle) MergeChanges(article *Article) (*Article, error)

Merge changes from the UpdateArticle-Request into an existing Article. Returns the modified Article or an error, if the UpdateArticle-Object is not valid.

Jump to

Keyboard shortcuts

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