store

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertRowStatusStringToStorepb

func ConvertRowStatusStringToStorepb(status string) storepb.RowStatus

Types

type Activity

type Activity struct {
	ID        int32
	CreatorID int32
	CreatedTs int64
	Type      ActivityType
	Level     ActivityLevel
	Payload   string
}

type ActivityLevel

type ActivityLevel string
const (
	// ActivityInfo is the activity level of info.
	ActivityInfo ActivityLevel = "INFO"
	// ActivityWarn is the activity level of warn.
	ActivityWarn ActivityLevel = "WARN"
	// ActivityError is the activity level of error.
	ActivityError ActivityLevel = "ERROR"
)

func (ActivityLevel) String

func (l ActivityLevel) String() string

type ActivityType

type ActivityType string
const (
	// ActivityShortcutView is the activity type of shortcut create.
	ActivityShortcutCreate ActivityType = "shortcut.create"
	// ActivityShortcutView is the activity type of shortcut view.
	ActivityShortcutView ActivityType = "shortcut.view"
)

func (ActivityType) String

func (t ActivityType) String() string

type DeleteCollection

type DeleteCollection struct {
	ID int32
}

type DeleteMemo

type DeleteMemo struct {
	ID int32
}

type DeleteShortcut

type DeleteShortcut struct {
	ID int32
}

type DeleteUser

type DeleteUser struct {
	ID int32
}

type Driver

type Driver interface {
	GetDB() *sql.DB
	Close() error

	Migrate(ctx context.Context) error

	// MigrationHistory model related methods.
	UpsertMigrationHistory(ctx context.Context, upsert *UpsertMigrationHistory) (*MigrationHistory, error)
	ListMigrationHistories(ctx context.Context, find *FindMigrationHistory) ([]*MigrationHistory, error)

	// Activity model related methods.
	CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
	ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)

	// Collection model related methods.
	CreateCollection(ctx context.Context, create *storepb.Collection) (*storepb.Collection, error)
	UpdateCollection(ctx context.Context, update *UpdateCollection) (*storepb.Collection, error)
	ListCollections(ctx context.Context, find *FindCollection) ([]*storepb.Collection, error)
	DeleteCollection(ctx context.Context, delete *DeleteCollection) error

	// Memo model related methods.
	CreateMemo(ctx context.Context, create *storepb.Memo) (*storepb.Memo, error)
	UpdateMemo(ctx context.Context, update *UpdateMemo) (*storepb.Memo, error)
	ListMemos(ctx context.Context, find *FindMemo) ([]*storepb.Memo, error)
	DeleteMemo(ctx context.Context, delete *DeleteMemo) error

	// Shortcut model related methods.
	CreateShortcut(ctx context.Context, create *storepb.Shortcut) (*storepb.Shortcut, error)
	UpdateShortcut(ctx context.Context, update *UpdateShortcut) (*storepb.Shortcut, error)
	ListShortcuts(ctx context.Context, find *FindShortcut) ([]*storepb.Shortcut, error)
	DeleteShortcut(ctx context.Context, delete *DeleteShortcut) error

	// User model related methods.
	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

	// UserSetting model related methods.
	UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
	ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)

	// WorkspaceSetting model related methods.
	UpsertWorkspaceSetting(ctx context.Context, upsert *storepb.WorkspaceSetting) (*storepb.WorkspaceSetting, error)
	ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSetting) ([]*storepb.WorkspaceSetting, error)
}

Driver is an interface for store driver. It contains all methods that store database driver should implement.

type FindActivity

type FindActivity struct {
	Type              ActivityType
	Level             ActivityLevel
	PayloadShortcutID *int32
}

type FindCollection

type FindCollection struct {
	ID             *int32
	CreatorID      *int32
	Name           *string
	VisibilityList []Visibility
}

type FindMemo

type FindMemo struct {
	ID             *int32
	CreatorID      *int32
	RowStatus      *RowStatus
	Name           *string
	VisibilityList []Visibility
	Tag            *string
}

type FindMigrationHistory

type FindMigrationHistory struct {
}

type FindShortcut

type FindShortcut struct {
	ID             *int32
	CreatorID      *int32
	RowStatus      *RowStatus
	Name           *string
	VisibilityList []Visibility
	Tag            *string
}

type FindUser

type FindUser struct {
	ID        *int32
	RowStatus *RowStatus
	Email     *string
	Nickname  *string
	Role      *Role
}

type FindUserSetting

type FindUserSetting struct {
	UserID *int32
	Key    storepb.UserSettingKey
}

type FindWorkspaceSetting

type FindWorkspaceSetting struct {
	Key storepb.WorkspaceSettingKey
}

type MigrationHistory

type MigrationHistory struct {
	Version   string
	CreatedTs int64
}

type Role

type Role string

Role is the type of a role.

const (
	// RoleAdmin is the ADMIN role.
	RoleAdmin Role = "ADMIN"
	// RoleUser is the USER role.
	RoleUser Role = "USER"
)

type RowStatus

type RowStatus string

RowStatus is the status for a row.

const (
	// Normal is the status for a normal row.
	Normal RowStatus = "NORMAL"
	// Archived is the status for an archived row.
	Archived RowStatus = "ARCHIVED"
)

func (RowStatus) String

func (e RowStatus) String() string

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store provides database access to all raw objects.

func New

func New(driver Driver, profile *profile.Profile) *Store

New creates a new instance of Store.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) CreateActivity

func (s *Store) CreateActivity(ctx context.Context, create *Activity) (*Activity, error)

func (*Store) CreateCollection

func (s *Store) CreateCollection(ctx context.Context, create *storepb.Collection) (*storepb.Collection, error)

func (*Store) CreateMemo

func (s *Store) CreateMemo(ctx context.Context, create *storepb.Memo) (*storepb.Memo, error)

func (*Store) CreateShortcut

func (s *Store) CreateShortcut(ctx context.Context, create *storepb.Shortcut) (*storepb.Shortcut, error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error)

func (*Store) DeleteCollection

func (s *Store) DeleteCollection(ctx context.Context, delete *DeleteCollection) error

func (*Store) DeleteMemo

func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error

func (*Store) DeleteShortcut

func (s *Store) DeleteShortcut(ctx context.Context, delete *DeleteShortcut) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) error

func (*Store) GetActivity

func (s *Store) GetActivity(ctx context.Context, find *FindActivity) (*Activity, error)

func (*Store) GetCollection

func (s *Store) GetCollection(ctx context.Context, find *FindCollection) (*storepb.Collection, error)

func (*Store) GetMemo

func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*storepb.Memo, error)

func (*Store) GetShortcut

func (s *Store) GetShortcut(ctx context.Context, find *FindShortcut) (*storepb.Shortcut, error)

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error)

func (*Store) GetUserAccessTokens

func (s *Store) GetUserAccessTokens(ctx context.Context, userID int32) ([]*storepb.AccessTokensUserSetting_AccessToken, error)

GetUserAccessTokens returns the access tokens of the user.

func (*Store) GetUserSetting

func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)

func (*Store) GetWorkspaceSetting

func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error)

func (*Store) ListActivities

func (s *Store) ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)

func (*Store) ListCollections

func (s *Store) ListCollections(ctx context.Context, find *FindCollection) ([]*storepb.Collection, error)

func (*Store) ListMemos

func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*storepb.Memo, error)

func (*Store) ListShortcuts

func (s *Store) ListShortcuts(ctx context.Context, find *FindShortcut) ([]*storepb.Shortcut, error)

func (*Store) ListUserSettings

func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)

func (*Store) ListWorkspaceSettings

func (s *Store) ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSetting) ([]*storepb.WorkspaceSetting, error)

func (*Store) UpdateCollection

func (s *Store) UpdateCollection(ctx context.Context, update *UpdateCollection) (*storepb.Collection, error)

func (*Store) UpdateMemo

func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) (*storepb.Memo, error)

func (*Store) UpdateShortcut

func (s *Store) UpdateShortcut(ctx context.Context, update *UpdateShortcut) (*storepb.Shortcut, error)

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)

func (*Store) UpsertUserSetting

func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)

func (*Store) UpsertWorkspaceSetting

func (s *Store) UpsertWorkspaceSetting(ctx context.Context, upsert *storepb.WorkspaceSetting) (*storepb.WorkspaceSetting, error)

type UpdateCollection

type UpdateCollection struct {
	ID int32

	RowStatus   *RowStatus
	Name        *string
	Link        *string
	Title       *string
	Description *string
	ShortcutIDs []int32
	Visibility  *Visibility
}

type UpdateMemo

type UpdateMemo struct {
	ID         int32
	RowStatus  *RowStatus
	Name       *string
	Title      *string
	Content    *string
	Visibility *Visibility
	Tag        *string
}

type UpdateShortcut

type UpdateShortcut struct {
	ID int32

	RowStatus         *RowStatus
	Name              *string
	Link              *string
	Title             *string
	Description       *string
	Visibility        *Visibility
	Tag               *string
	OpenGraphMetadata *storepb.OpenGraphMetadata
}

type UpdateUser

type UpdateUser struct {
	ID int32

	RowStatus    *RowStatus
	Email        *string
	Nickname     *string
	PasswordHash *string
	Role         *Role
}

type UpsertMigrationHistory

type UpsertMigrationHistory struct {
	Version string
}

type User

type User struct {
	ID int32

	// Standard fields
	CreatedTs int64
	UpdatedTs int64
	RowStatus RowStatus

	// Domain specific fields
	Email        string
	Nickname     string
	PasswordHash string
	Role         Role
}

type Visibility

type Visibility string

Visibility is the type of a visibility.

const (
	// VisibilityPublic is the PUBLIC visibility.
	VisibilityPublic Visibility = "PUBLIC"
	// VisibilityWorkspace is the WORKSPACE visibility.
	VisibilityWorkspace Visibility = "WORKSPACE"
	// VisibilityPrivate is the PRIVATE visibility.
	VisibilityPrivate Visibility = "PRIVATE"
)

func (Visibility) String

func (e Visibility) String() string

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL