GraphQL API and utilities for the rpdata project
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.
 
 

33 lines
854 B

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"`
Date time.Time `bson:"date"`
Logs []Log `bson:"logs"`
Characters []Character `bson:"characters"`
Posts []Post `bson:"posts"`
}
// 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.Posts))
for _, log := range change.Logs {
data = append(data, log)
}
for _, character := range change.Characters {
data = append(data, character)
}
for _, post := range change.Posts {
data = append(data, post)
}
return data
}