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

  1. package models
  2. import "time"
  3. // Change represents a change in the rpdata history through the API.
  4. type Change struct {
  5. ID string `bson:"_id"`
  6. Model string `bson:"model"`
  7. Op string `bson:"op"`
  8. Author string `bson:"author"`
  9. Date time.Time `bson:"date"`
  10. Logs []Log `bson:"logs"`
  11. Characters []Character `bson:"characters"`
  12. Posts []Post `bson:"posts"`
  13. }
  14. // Data makes a combined, mixed array of all the models stored in this change.
  15. func (change *Change) Data() []interface{} {
  16. data := make([]interface{}, 0, len(change.Logs)+len(change.Characters)+len(change.Posts))
  17. for _, log := range change.Logs {
  18. data = append(data, log)
  19. }
  20. for _, character := range change.Characters {
  21. data = append(data, character)
  22. }
  23. for _, post := range change.Posts {
  24. data = append(data, post)
  25. }
  26. return data
  27. }