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.

41 lines
1010 B

  1. package services
  2. import (
  3. "git.aiterp.net/rpdata/api/database"
  4. "git.aiterp.net/rpdata/api/services/loaders"
  5. )
  6. // A Bundle contains all services.
  7. type Bundle struct {
  8. Tags *TagService
  9. Characters *CharacterService
  10. Changes *ChangeService
  11. Logs *LogService
  12. Channels *ChannelService
  13. }
  14. // NewBundle creates a new bundle.
  15. func NewBundle(db database.Database) *Bundle {
  16. bundle := &Bundle{}
  17. bundle.Changes = &ChangeService{
  18. changes: db.Changes(),
  19. }
  20. bundle.Tags = &TagService{tags: db.Tags()}
  21. bundle.Characters = &CharacterService{
  22. characters: db.Characters(),
  23. loader: loaders.CharacterLoaderFromRepository(db.Characters()),
  24. changeService: bundle.Changes,
  25. }
  26. bundle.Channels = &ChannelService{
  27. channels: db.Channels(),
  28. loader: loaders.ChannelLoaderFromRepository(db.Channels()),
  29. changeService: bundle.Changes,
  30. }
  31. bundle.Logs = &LogService{
  32. logs: db.Logs(),
  33. posts: db.Posts(),
  34. changeService: bundle.Changes,
  35. }
  36. return bundle
  37. }