2023-09-26 12:16:58 +03:00
|
|
|
package store
|
|
|
|
|
2023-09-26 14:02:48 +03:00
|
|
|
import (
|
|
|
|
"context"
|
2023-09-29 04:15:54 +03:00
|
|
|
"database/sql"
|
2023-09-26 14:02:48 +03:00
|
|
|
|
|
|
|
storepb "github.com/usememos/memos/proto/gen/store"
|
|
|
|
)
|
2023-09-26 12:16:58 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// Driver is an interface for store driver.
|
|
|
|
// It contains all methods that store database driver should implement.
|
2023-09-26 12:16:58 +03:00
|
|
|
type Driver interface {
|
2023-09-29 04:15:54 +03:00
|
|
|
GetDB() *sql.DB
|
2023-09-27 06:56:20 +03:00
|
|
|
Close() error
|
|
|
|
|
|
|
|
Migrate(ctx context.Context) error
|
2023-09-27 04:27:31 +03:00
|
|
|
Vacuum(ctx context.Context) error
|
|
|
|
BackupTo(ctx context.Context, filename string) error
|
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// Activity model related methods.
|
2023-09-26 12:16:58 +03:00
|
|
|
CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
|
2023-10-09 16:18:33 +03:00
|
|
|
ListActivity(ctx context.Context, find *FindActivity) ([]*Activity, error)
|
2023-09-26 12:16:58 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// Resource model related methods.
|
2023-09-26 14:04:07 +03: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 18:11:29 +03:00
|
|
|
// Memo model related methods.
|
2023-09-27 03:57:12 +03: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
|
|
|
|
FindMemosVisibilityList(ctx context.Context, memoIDs []int32) ([]Visibility, error)
|
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// MemoRelation model related methods.
|
2023-09-27 03:43:46 +03: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 18:11:29 +03:00
|
|
|
// MemoOrganizer model related methods.
|
2023-09-27 03:54:50 +03:00
|
|
|
UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error)
|
2023-10-09 16:18:47 +03:00
|
|
|
ListMemoOrganizer(ctx context.Context, find *FindMemoOrganizer) ([]*MemoOrganizer, error)
|
2023-09-27 03:54:50 +03:00
|
|
|
DeleteMemoOrganizer(ctx context.Context, delete *DeleteMemoOrganizer) error
|
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// SystemSetting model related methods.
|
2023-09-26 12:16:58 +03:00
|
|
|
UpsertSystemSetting(ctx context.Context, upsert *SystemSetting) (*SystemSetting, error)
|
|
|
|
ListSystemSettings(ctx context.Context, find *FindSystemSetting) ([]*SystemSetting, error)
|
2023-09-26 13:23:45 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// User model related methods.
|
2023-09-26 13:23:45 +03: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 14:02:48 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// UserSetting model related methods.
|
2023-09-26 14:02:48 +03:00
|
|
|
UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error)
|
|
|
|
ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error)
|
|
|
|
UpsertUserSettingV1(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
|
|
|
|
ListUserSettingsV1(ctx context.Context, find *FindUserSettingV1) ([]*storepb.UserSetting, error)
|
2023-09-26 14:17:17 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// IdentityProvider model related methods.
|
2023-09-26 14:17:17 +03:00
|
|
|
CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
|
|
|
|
ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
|
|
|
|
GetIdentityProvider(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 14:37:22 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// Tag model related methods.
|
2023-09-26 14:37:22 +03: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 14:43:55 +03:00
|
|
|
|
2023-10-05 18:11:29 +03:00
|
|
|
// Storage model related methods.
|
2023-09-26 14:43:55 +03:00
|
|
|
CreateStorage(ctx context.Context, create *Storage) (*Storage, error)
|
|
|
|
ListStorages(ctx context.Context, find *FindStorage) ([]*Storage, error)
|
|
|
|
GetStorage(ctx context.Context, find *FindStorage) (*Storage, error)
|
|
|
|
UpdateStorage(ctx context.Context, update *UpdateStorage) (*Storage, error)
|
|
|
|
DeleteStorage(ctx context.Context, delete *DeleteStorage) error
|
2023-09-26 12:16:58 +03:00
|
|
|
}
|