driver.go 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package store
  2. import (
  3. "context"
  4. "database/sql"
  5. )
  6. // Driver is an interface for store driver.
  7. // It contains all methods that store database driver should implement.
  8. type Driver interface {
  9. GetDB() *sql.DB
  10. Close() error
  11. Migrate(ctx context.Context) error
  12. // current file is driver
  13. GetCurrentDBSize(ctx context.Context) (int64, error)
  14. // MigrationHistory model related methods.
  15. FindMigrationHistoryList(ctx context.Context, find *FindMigrationHistory) ([]*MigrationHistory, error)
  16. UpsertMigrationHistory(ctx context.Context, upsert *UpsertMigrationHistory) (*MigrationHistory, error)
  17. // Activity model related methods.
  18. CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
  19. ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)
  20. // Resource model related methods.
  21. CreateResource(ctx context.Context, create *Resource) (*Resource, error)
  22. ListResources(ctx context.Context, find *FindResource) ([]*Resource, error)
  23. UpdateResource(ctx context.Context, update *UpdateResource) error
  24. DeleteResource(ctx context.Context, delete *DeleteResource) error
  25. // Memo model related methods.
  26. CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
  27. ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
  28. UpdateMemo(ctx context.Context, update *UpdateMemo) error
  29. DeleteMemo(ctx context.Context, delete *DeleteMemo) error
  30. // MemoRelation model related methods.
  31. UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
  32. ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
  33. DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
  34. // MemoOrganizer model related methods.
  35. UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error)
  36. ListMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) ([]*MemoOrganizer, error)
  37. DeleteMemoOrganizer(ctx context.Context, delete *DeleteMemoOrganizer) error
  38. // WorkspaceSetting model related methods.
  39. UpsertWorkspaceSetting(ctx context.Context, upsert *WorkspaceSetting) (*WorkspaceSetting, error)
  40. ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSetting) ([]*WorkspaceSetting, error)
  41. DeleteWorkspaceSetting(ctx context.Context, delete *DeleteWorkspaceSetting) error
  42. // User model related methods.
  43. CreateUser(ctx context.Context, create *User) (*User, error)
  44. UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
  45. ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
  46. DeleteUser(ctx context.Context, delete *DeleteUser) error
  47. // UserSetting model related methods.
  48. UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error)
  49. ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error)
  50. // IdentityProvider model related methods.
  51. CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
  52. ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
  53. UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProvider) (*IdentityProvider, error)
  54. DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
  55. // Inbox model related methods.
  56. CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
  57. ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
  58. UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
  59. DeleteInbox(ctx context.Context, delete *DeleteInbox) error
  60. // Webhook model related methods.
  61. CreateWebhook(ctx context.Context, create *Webhook) (*Webhook, error)
  62. ListWebhooks(ctx context.Context, find *FindWebhook) ([]*Webhook, error)
  63. UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*Webhook, error)
  64. DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error
  65. // Reaction model related methods.
  66. UpsertReaction(ctx context.Context, create *Reaction) (*Reaction, error)
  67. ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
  68. DeleteReaction(ctx context.Context, delete *DeleteReaction) error
  69. }