This commit is contained in:
@@ -26,6 +26,8 @@ const (
|
||||
ChangeModelChapter ChangeModel = "Chapter"
|
||||
// ChangeModelComment is a value of ChangeModel
|
||||
ChangeModelComment ChangeModel = "Comment"
|
||||
// ChangeModelFile is a value of ChangeModel
|
||||
ChangeModelFile ChangeModel = "File"
|
||||
)
|
||||
|
||||
// IsValid returns true if the underlying string is one of the correct values.
|
||||
|
||||
@@ -23,6 +23,7 @@ type Change struct {
|
||||
Tags []*Tag `bson:"tags"`
|
||||
Chapters []*Chapter `bson:"chapters"`
|
||||
Comments []*Comment `bson:"comments"`
|
||||
Files []*File `bson:"files"`
|
||||
}
|
||||
|
||||
// AddObject adds the model into the appropriate array.
|
||||
@@ -68,6 +69,10 @@ func (change *Change) AddObject(object interface{}) bool {
|
||||
change.Comments = append(change.Comments, object)
|
||||
case []*Comment:
|
||||
change.Comments = append(change.Comments, object...)
|
||||
case *File:
|
||||
change.Files = append(change.Files, object)
|
||||
case []*File:
|
||||
change.Files = append(change.Files, object...)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@@ -103,6 +108,9 @@ func (change *Change) Objects() []interface{} {
|
||||
for _, comment := range change.Comments {
|
||||
data = append(data, comment)
|
||||
}
|
||||
for _, file := range change.Files {
|
||||
data = append(data, file)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user