/
documents.go
36 lines (32 loc) · 1.34 KB
/
documents.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
package task
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// NewTaskDocument is an intermediary data type that is
// used by a repository layer that impements mongo
// to communicate with the mongodb driver API.
type NewTaskDocument struct {
UserID primitive.ObjectID `bson:"userId,omitempty"`
Name string `bson:"name"`
Details string `bson:"details,omitempty"`
Priority string `bson:"priority,omitempty"`
Category string `bson:"category,omitempty"`
CreatedAt *time.Time `bson:"createdAt,omitempty"`
UpdatedAt *time.Time `bson:"updatedAt,omitempty"`
}
// TaskDocument is a data type used by
// a repository layer that implements mongo
// to communicate with the mongo API.
// The 'omitempty' tag is used to prevent an empty
// field value from whiping a document during an update.
type TaskDocument struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
UserID primitive.ObjectID `bson:"userId,omitempty"`
Name string `bson:"name,omitempty"`
Details string `bson:"details,omitempty"`
Priority string `bson:"priority,omitempty"`
Category string `bson:"category,omitempty"`
CreatedAt *time.Time `bson:"createdAt,omitempty"`
UpdatedAt *time.Time `bson:"updatedAt,omitempty"`
}