2023-09-26 17:16:58 +08:00
|
|
|
package store
|
|
|
|
|
2023-09-26 19:02:48 +08:00
|
|
|
import (
|
|
|
|
"context"
|
2023-09-29 09:15:54 +08:00
|
|
|
"database/sql"
|
2023-09-26 19:02:48 +08:00
|
|
|
|
|
|
|
storepb "github.com/usememos/memos/proto/gen/store"
|
|
|
|
)
|
2023-09-26 17:16:58 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Driver is an interface for store driver.
|
|
|
|
// It contains all methods that store database driver should implement.
|
2023-09-26 17:16:58 +08:00
|
|
|
type Driver interface {
|
2023-09-29 09:15:54 +08:00
|
|
|
GetDB() *sql.DB
|
2023-09-27 11:56:20 +08:00
|
|
|
Close() error
|
|
|
|
|
|
|
|
Migrate(ctx context.Context) error
|
2023-09-27 09:27:31 +08:00
|
|
|
Vacuum(ctx context.Context) error
|
|
|
|
|
2023-10-16 21:07:21 +08:00
|
|
|
// current file is driver
|
|
|
|
GetCurrentDBSize(ctx context.Context) (int64, error)
|
|
|
|
|
2023-11-06 08:33:31 +08:00
|
|
|
// MigrationHistory model related methods.
|
|
|
|
FindMigrationHistoryList(ctx context.Context, find *FindMigrationHistory) ([]*MigrationHistory, error)
|
|
|
|
UpsertMigrationHistory(ctx context.Context, upsert *UpsertMigrationHistory) (*MigrationHistory, error)
|
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Activity model related methods.
|
2023-09-26 17:16:58 +08:00
|
|
|
CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
|
2023-10-27 01:11:41 +08:00
|
|
|
ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)
|
2023-09-26 17:16:58 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Resource model related methods.
|
2023-09-26 19:04:07 +08:00
|
|
|
CreateResource(ctx context.Context, create *Resource) (*Resource, error)
|
|
|
|
ListResources(ctx context.Context, find *FindResource) ([]*Resource, error)
|
|
|
|
UpdateResource(ctx context.Context, update *UpdateResource) (*Resource, error)
|
|
|
|
DeleteResource(ctx context.Context, delete *DeleteResource) error
|
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Memo model related methods.
|
2023-09-27 08:57:12 +08:00
|
|
|
CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
|
|
|
|
ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
|
|
|
|
UpdateMemo(ctx context.Context, update *UpdateMemo) error
|
|
|
|
DeleteMemo(ctx context.Context, delete *DeleteMemo) error
|
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// MemoRelation model related methods.
|
2023-09-27 08:43:46 +08:00
|
|
|
UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
|
|
|
|
ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
|
|
|
|
DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
|
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// MemoOrganizer model related methods.
|
2023-09-27 08:54:50 +08:00
|
|
|
UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error)
|
2023-10-09 21:18:47 +08:00
|
|
|
ListMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) ([]*MemoOrganizer, error)
|
2023-09-27 08:54:50 +08:00
|
|
|
DeleteMemoOrganizer(ctx context.Context, delete *DeleteMemoOrganizer) error
|
|
|
|
|
2024-01-29 22:43:40 +08:00
|
|
|
// WorkspaceSetting model related methods.
|
|
|
|
UpsertWorkspaceSetting(ctx context.Context, upsert *WorkspaceSetting) (*WorkspaceSetting, error)
|
|
|
|
ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSetting) ([]*WorkspaceSetting, error)
|
2024-02-23 08:40:33 +08:00
|
|
|
DeleteWorkspaceSetting(ctx context.Context, delete *DeleteWorkspaceSetting) error
|
2024-02-20 23:02:01 +08:00
|
|
|
UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.WorkspaceSetting) (*storepb.WorkspaceSetting, error)
|
|
|
|
ListWorkspaceSettingsV1(ctx context.Context, find *FindWorkspaceSettingV1) ([]*storepb.WorkspaceSetting, error)
|
2023-09-26 18:23:45 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// User model related methods.
|
2023-09-26 18:23:45 +08:00
|
|
|
CreateUser(ctx context.Context, create *User) (*User, error)
|
|
|
|
UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
|
|
|
|
ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
|
|
|
|
DeleteUser(ctx context.Context, delete *DeleteUser) error
|
2023-09-26 19:02:48 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// UserSetting model related methods.
|
2023-12-08 22:41:47 +08:00
|
|
|
UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
|
|
|
|
ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)
|
2023-09-26 19:17:17 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// IdentityProvider model related methods.
|
2023-09-26 19:17:17 +08:00
|
|
|
CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
|
|
|
|
ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
|
|
|
|
UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProvider) (*IdentityProvider, error)
|
|
|
|
DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
|
2023-09-26 19:37:22 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Tag model related methods.
|
2023-09-26 19:37:22 +08:00
|
|
|
UpsertTag(ctx context.Context, upsert *Tag) (*Tag, error)
|
|
|
|
ListTags(ctx context.Context, find *FindTag) ([]*Tag, error)
|
|
|
|
DeleteTag(ctx context.Context, delete *DeleteTag) error
|
2023-09-26 19:43:55 +08:00
|
|
|
|
2023-10-05 23:11:29 +08:00
|
|
|
// Storage model related methods.
|
2023-09-26 19:43:55 +08:00
|
|
|
CreateStorage(ctx context.Context, create *Storage) (*Storage, error)
|
|
|
|
ListStorages(ctx context.Context, find *FindStorage) ([]*Storage, error)
|
|
|
|
UpdateStorage(ctx context.Context, update *UpdateStorage) (*Storage, error)
|
|
|
|
DeleteStorage(ctx context.Context, delete *DeleteStorage) error
|
2023-10-27 01:10:19 +08:00
|
|
|
|
|
|
|
// Inbox model related methods.
|
|
|
|
CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
|
2023-10-28 00:08:42 +08:00
|
|
|
ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
|
2023-10-27 01:10:19 +08:00
|
|
|
UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
|
|
|
|
DeleteInbox(ctx context.Context, delete *DeleteInbox) error
|
2023-11-24 22:45:38 +08:00
|
|
|
|
|
|
|
// Webhook model related methods.
|
|
|
|
CreateWebhook(ctx context.Context, create *storepb.Webhook) (*storepb.Webhook, error)
|
|
|
|
ListWebhooks(ctx context.Context, find *FindWebhook) ([]*storepb.Webhook, error)
|
|
|
|
UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*storepb.Webhook, error)
|
|
|
|
DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error
|
2024-02-07 23:40:23 +08:00
|
|
|
|
|
|
|
// Reaction model related methods.
|
2024-02-08 11:54:59 +08:00
|
|
|
UpsertReaction(ctx context.Context, create *storepb.Reaction) (*storepb.Reaction, error)
|
2024-02-07 23:40:23 +08:00
|
|
|
ListReactions(ctx context.Context, find *FindReaction) ([]*storepb.Reaction, error)
|
|
|
|
DeleteReaction(ctx context.Context, delete *DeleteReaction) error
|
2023-09-26 17:16:58 +08:00
|
|
|
}
|