models

package
v0.0.0-...-520c8c8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorModel

type ErrorModel struct {
	Code     int         `json:"code"`
	Err      string      `json:"error"`
	Desc     string      `json:"desc"`
	Internal interface{} `json:"internal"`
}

ErrorModel stands for server error.

type Mongo

type Mongo struct {
	ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
}

Mongo stands for mongo BSON ObjectID type.

type Page

type Page struct {
	Title string      `json:"title`
	Data  interface{} `json:"data"`
}

Page stands for template to handle.

type Post

type Post struct {
	Mongo   `bson:"inline"`
	Title   string        `bson:"title" json:"title"`
	Author  string        `bson:"author" json:"author"`
	Content template.HTML `bson:"content" json:"content"`
}

Post stands for post object.

func AllPosts

func AllPosts(ctx context.Context, db *mongo.Database) ([]Post, error)

AllPosts return all posts from database.

func GetPost

func GetPost(ctx context.Context, db *mongo.Database, id string) (*Post, error)

GetPost gets post by id.

func (*Post) Delete

func (p *Post) Delete(ctx context.Context, db *mongo.Database) (*Post, error)

Delete deletes post from database.

func (*Post) Insert

func (p *Post) Insert(ctx context.Context, db *mongo.Database) error

Insert post to database.

func (*Post) Update

func (p *Post) Update(ctx context.Context, db *mongo.Database) (*Post, error)

Update updates post in database.

Jump to

Keyboard shortcuts

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