2020-09-17 20:33:58 +02:00
|
|
|
package model
|
|
|
|
|
2020-09-26 22:38:38 +02:00
|
|
|
import (
|
|
|
|
"github.com/Kamva/mgm/v3"
|
|
|
|
)
|
|
|
|
|
2020-09-17 20:33:58 +02:00
|
|
|
// Article type
|
|
|
|
type Article struct {
|
2020-09-26 22:38:38 +02:00
|
|
|
mgm.DefaultModel `bson:",inline"`
|
|
|
|
Title string `json:"title" bson:"title" validate:"required"`
|
|
|
|
Description string `json:"description" bson:"description" validate:"required"`
|
|
|
|
Content string `json:"content" bson:"content" validate:"required"`
|
2020-09-17 20:33:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Articles Collection
|
|
|
|
type Articles []Article
|
2020-09-26 22:38:38 +02:00
|
|
|
|
2020-09-29 22:35:59 +02:00
|
|
|
// NewArticle create new Article
|
2020-09-26 22:38:38 +02:00
|
|
|
func NewArticle(title string, desc string, content string) *Article {
|
|
|
|
return &Article{
|
|
|
|
Title: title,
|
|
|
|
Description: desc,
|
|
|
|
Content: content,
|
|
|
|
}
|
|
|
|
}
|