/
board.go
40 lines (31 loc) · 1.07 KB
/
board.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package types
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
var (
// permissions
PUBLIC_BOARD_FIELDS = []string{"title", "short", "description", "threads", "created_at", "updated_at", "deleted_at"}
)
type Board struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
Title string `bson:"title" json:"title"`
Short string `bson:"short" json:"short"` // short name for the board (used in URLs)
Description string `bson:"description" json:"description"`
Threads []primitive.ObjectID `bson:"threads,omitempty" json:"threads,omitempty"`
CreatedAt *time.Time `bson:"created_at" json:"created_at"`
UpdatedAt *time.Time `bson:"updated_at" json:"updated_at"`
DeletedAt *time.Time `bson:"deleted_at,omitempty" json:"deleted_at,omitempty"`
PostRef uint64 `bson:"post_ref" json:"post_ref"`
}
// Creates a new board with an ID and other default values.
func NewBoard() *Board {
ts := time.Now().UTC()
return &Board{
ID: primitive.NewObjectID(),
Threads: []primitive.ObjectID{},
CreatedAt: &ts,
UpdatedAt: &ts,
PostRef: 0,
}
}