You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
package models
|
|
|
|
import "time"
|
|
|
|
// Change represents a change in the rpdata history through the API.
|
|
type Change struct {
|
|
ID string `bson:"_id"`
|
|
Model string `bson:"model"`
|
|
Op string `bson:"op"`
|
|
Author string `bson:"author"`
|
|
Listed bool `bson:"listed"`
|
|
Keys []ChangeKey `bson:"keys"`
|
|
Date time.Time `bson:"date"`
|
|
|
|
Logs []Log `bson:"logs"`
|
|
Characters []Character `bson:"characters"`
|
|
Channels []Channel `bson:"channels"`
|
|
Posts []Post `bson:"posts"`
|
|
Stories []Story `bson:"stories"`
|
|
Tags []Tag `bson:"tags"`
|
|
Chapters []Chapter `bson:"chapters"`
|
|
}
|
|
|
|
// ChangeKey is a key for a change that can be used when subscribing to them.
|
|
type ChangeKey struct {
|
|
Model string `bson:"model"`
|
|
ID string `bson:"id"`
|
|
}
|
|
|
|
// Data makes a combined, mixed array of all the models stored in this change.
|
|
func (change *Change) Data() []interface{} {
|
|
data := make([]interface{}, 0, len(change.Logs)+len(change.Characters)+len(change.Channels)+len(change.Posts)+len(change.Stories)+len(change.Tags)+len(change.Chapters))
|
|
|
|
for _, log := range change.Logs {
|
|
data = append(data, log)
|
|
}
|
|
for _, channel := range change.Channels {
|
|
data = append(data, channel)
|
|
}
|
|
for _, character := range change.Characters {
|
|
data = append(data, character)
|
|
}
|
|
for _, post := range change.Posts {
|
|
data = append(data, post)
|
|
}
|
|
for _, story := range change.Stories {
|
|
data = append(data, story)
|
|
}
|
|
for _, tag := range change.Tags {
|
|
data = append(data, tag)
|
|
}
|
|
for _, chapter := range change.Chapters {
|
|
data = append(data, chapter)
|
|
}
|
|
|
|
return data
|
|
}
|