2021-08-06 14:10:24 +02:00
|
|
|
//go:generate mockgen --build_flags=--mod=mod -destination=mockstore/mockstore.go -package mockstore . Store
|
2021-10-22 12:48:53 +02:00
|
|
|
//go:generate go run ./generators/main.go
|
2020-10-16 19:20:43 +02:00
|
|
|
package store
|
|
|
|
|
2021-01-26 23:13:46 +01:00
|
|
|
import "github.com/mattermost/focalboard/server/model"
|
2020-10-16 19:20:43 +02:00
|
|
|
|
2021-03-26 19:01:54 +01:00
|
|
|
// Conainer represents a container in a store
|
2021-06-21 11:21:42 +02:00
|
|
|
// Using a struct to make extending this easier in the future.
|
2021-03-26 19:01:54 +01:00
|
|
|
type Container struct {
|
|
|
|
WorkspaceID string
|
|
|
|
}
|
|
|
|
|
2020-10-22 15:22:36 +02:00
|
|
|
// Store represents the abstraction of the data storage.
|
2020-10-16 19:20:43 +02:00
|
|
|
type Store interface {
|
2021-03-26 19:01:54 +01:00
|
|
|
GetBlocksWithParentAndType(c Container, parentID string, blockType string) ([]model.Block, error)
|
|
|
|
GetBlocksWithParent(c Container, parentID string) ([]model.Block, error)
|
2021-05-13 23:04:49 +02:00
|
|
|
GetBlocksWithRootID(c Container, rootID string) ([]model.Block, error)
|
2021-03-26 19:01:54 +01:00
|
|
|
GetBlocksWithType(c Container, blockType string) ([]model.Block, error)
|
|
|
|
GetSubTree2(c Container, blockID string) ([]model.Block, error)
|
|
|
|
GetSubTree3(c Container, blockID string) ([]model.Block, error)
|
|
|
|
GetAllBlocks(c Container) ([]model.Block, error)
|
|
|
|
GetRootID(c Container, blockID string) (string, error)
|
|
|
|
GetParentID(c Container, blockID string) (string, error)
|
2021-10-22 12:48:53 +02:00
|
|
|
// @withTransaction
|
2021-07-08 16:36:43 +02:00
|
|
|
InsertBlock(c Container, block *model.Block, userID string) error
|
2021-10-22 12:48:53 +02:00
|
|
|
// @withTransaction
|
2021-03-26 19:01:54 +01:00
|
|
|
DeleteBlock(c Container, blockID string, modifiedBy string) error
|
2021-06-04 16:38:49 +02:00
|
|
|
GetBlockCountsByType() (map[string]int64, error)
|
2021-07-08 16:36:43 +02:00
|
|
|
GetBlock(c Container, blockID string) (*model.Block, error)
|
2021-10-22 12:48:53 +02:00
|
|
|
// @withTransaction
|
2021-08-06 14:10:24 +02:00
|
|
|
PatchBlock(c Container, blockID string, blockPatch *model.BlockPatch, userID string) error
|
2021-01-13 00:35:30 +01:00
|
|
|
|
2020-10-16 22:26:47 +02:00
|
|
|
Shutdown() error
|
2021-01-13 00:35:30 +01:00
|
|
|
|
2020-10-19 14:55:20 +02:00
|
|
|
GetSystemSettings() (map[string]string, error)
|
2021-03-21 09:28:26 +01:00
|
|
|
SetSystemSetting(key, value string) error
|
2021-01-13 00:35:30 +01:00
|
|
|
|
2021-01-27 18:22:33 +01:00
|
|
|
GetRegisteredUserCount() (int, error)
|
2021-06-21 11:21:42 +02:00
|
|
|
GetUserByID(userID string) (*model.User, error)
|
2020-11-06 16:46:35 +01:00
|
|
|
GetUserByEmail(email string) (*model.User, error)
|
|
|
|
GetUserByUsername(username string) (*model.User, error)
|
|
|
|
CreateUser(user *model.User) error
|
|
|
|
UpdateUser(user *model.User) error
|
2021-03-21 09:28:26 +01:00
|
|
|
UpdateUserPassword(username, password string) error
|
|
|
|
UpdateUserPasswordByID(userID, password string) error
|
2021-06-04 15:23:15 +02:00
|
|
|
GetUsersByWorkspace(workspaceID string) ([]*model.User, error)
|
2021-01-13 00:35:30 +01:00
|
|
|
|
2021-01-27 19:01:24 +01:00
|
|
|
GetActiveUserCount(updatedSecondsAgo int64) (int, error)
|
2020-12-07 17:04:35 +01:00
|
|
|
GetSession(token string, expireTime int64) (*model.Session, error)
|
2020-12-02 21:12:14 +01:00
|
|
|
CreateSession(session *model.Session) error
|
|
|
|
RefreshSession(session *model.Session) error
|
|
|
|
UpdateSession(session *model.Session) error
|
2021-06-21 11:21:42 +02:00
|
|
|
DeleteSession(sessionID string) error
|
2020-12-07 17:04:35 +01:00
|
|
|
CleanUpSessions(expireTime int64) error
|
2021-01-13 00:35:30 +01:00
|
|
|
|
2021-03-26 19:01:54 +01:00
|
|
|
UpsertSharing(c Container, sharing model.Sharing) error
|
|
|
|
GetSharing(c Container, rootID string) (*model.Sharing, error)
|
2021-01-14 01:56:01 +01:00
|
|
|
|
|
|
|
UpsertWorkspaceSignupToken(workspace model.Workspace) error
|
|
|
|
UpsertWorkspaceSettings(workspace model.Workspace) error
|
|
|
|
GetWorkspace(ID string) (*model.Workspace, error)
|
2021-05-24 19:06:11 +02:00
|
|
|
HasWorkspaceAccess(userID string, workspaceID string) (bool, error)
|
2021-06-04 16:38:49 +02:00
|
|
|
GetWorkspaceCount() (int64, error)
|
2021-09-08 06:52:03 +02:00
|
|
|
GetUserWorkspaces(userID string) ([]model.UserWorkspace, error)
|
2020-10-16 19:20:43 +02:00
|
|
|
}
|