Otfe/models/post.go

34 lines
461 B
Go
Raw Permalink Normal View History

2022-02-23 12:07:09 +00:00
package models
import (
"time"
"github.com/jinzhu/gorm"
)
//Post model
type Post struct {
gorm.Model
Title string
Author string
Published time.Time
LastEdited time.Time
Content []byte
}
//Create new post
func (p Post) Create() error {
return create(&p)
}
func (p *Post) Read() (*Post, error) {
err := read(&p)
return p, err
}
func (p Post) ReadAll() ([]Post, error) {
var posts []Post
err := readAll(&posts)
return posts, err
}