Loggest thy stuff
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.

39 lines
1.4 KiB

  1. package database
  2. import (
  3. "context"
  4. "git.aiterp.net/stufflog3/stufflog3-api/internal/models"
  5. "time"
  6. )
  7. type Database interface {
  8. Scopes() ScopeRepository
  9. Stats(scopeID int) StatRepository
  10. Items(scopeID int) ItemRepository
  11. }
  12. type ScopeRepository interface {
  13. Find(ctx context.Context, id int) (*models.Scope, error)
  14. List(ctx context.Context) ([]models.ScopeEntry, error)
  15. ListByUser(ctx context.Context, userID string) ([]models.ScopeEntry, error)
  16. Create(ctx context.Context, scope models.ScopeEntry, owner models.ScopeMember) (*models.Scope, error)
  17. Update(ctx context.Context, scope models.ScopeEntry) error
  18. Delete(ctx context.Context, scope models.Scope) error
  19. UpdateMember(ctx context.Context, scope models.Scope, member models.ScopeMember) (*models.Scope, error)
  20. DeleteMember(ctx context.Context, scope models.Scope, userID string) (*models.Scope, error)
  21. }
  22. type StatRepository interface {
  23. Find(ctx context.Context, id int) (*models.Stat, error)
  24. List(ctx context.Context) ([]models.Stat, error)
  25. Create(ctx context.Context, stat models.Stat) (*models.Stat, error)
  26. Update(ctx context.Context, stat models.Stat) error
  27. Delete(ctx context.Context, stat models.Stat) error
  28. }
  29. type ItemRepository interface {
  30. Find(ctx context.Context, id int) (*models.Item, error)
  31. List(ctx context.Context) ([]models.Item, error)
  32. ListAcquired(ctx context.Context, from, to time.Time) ([]models.Item, error)
  33. Create(ctx context.Context, stat models.Stat) (*models.Item, error)
  34. }