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.

51 lines
1.0 KiB

  1. package models
  2. import "time"
  3. // A Post is a part of a log file.
  4. type Post struct {
  5. ID string `bson:"_id"`
  6. LogID string `bson:"logId"`
  7. Time time.Time `bson:"time"`
  8. Kind string `bson:"kind"`
  9. Nick string `bson:"nick"`
  10. Text string `bson:"text"`
  11. Position int `bson:"position"`
  12. }
  13. func (post *Post) ApplyUpdate(update PostUpdate) {
  14. if update.Time != nil {
  15. post.Time = *update.Time
  16. }
  17. if update.Kind != nil {
  18. post.Kind = *update.Kind
  19. }
  20. if update.Nick != nil {
  21. post.Nick = *update.Nick
  22. }
  23. if update.Text != nil {
  24. post.Text = *update.Text
  25. }
  26. }
  27. // IsChangeObject is an interface implementation to identify it as a valid
  28. // ChangeObject in GQL.
  29. func (*Post) IsChangeObject() {
  30. panic("this method is a dummy, and so is its caller")
  31. }
  32. // PostFilter is used to generate a query to the database.
  33. type PostFilter struct {
  34. IDs []string
  35. Kinds []string
  36. LogID *string
  37. Search *string
  38. Limit int
  39. }
  40. type PostUpdate struct {
  41. Time *time.Time
  42. Kind *string
  43. Nick *string
  44. Text *string
  45. }