post

package
v0.0.0-...-172aab7 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(filter bson.M) int

Count posts

Types

type Post

type Post struct {
	ID         primitive.ObjectID   `bson:"_id" json:"id"`
	User       primitive.ObjectID   `bson:"_user" json:"user"`
	Title      string               `bson:"title" json:"title"`
	Content    string               `bson:"content" json:"content"`
	Categories []primitive.ObjectID `bson:"_categories" json:"categories"`
	Tags       []string             `bson:"tags" json:"tags"`
	Thumbnail  primitive.ObjectID   `bson:"thumbnail" json:"thumbnail"`
	CreatedAt  time.Time            `bson:"created_at" json:"created_at"`
}

Post Model

func Find

func Find(filter bson.M, page, limit int, sorts ...bson.E) []Post

Find posts

func FindOne

func FindOne(filter bson.M) (*Post, error)

FindOne post

func (*Post) Delete

func (p *Post) Delete() error

Delete a post

func (*Post) Insert

func (p *Post) Insert() error

Insert new Post

func (*Post) Save

func (p *Post) Save() error

Save a Post insert or update

func (*Post) Update

func (p *Post) Update() error

Update a Post

Jump to

Keyboard shortcuts

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