store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FireStore

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

FireStore implements the Store interface with Google Firestore

func NewFireStore

func NewFireStore(project string) *FireStore

NewFireStore initializes a FireStore

func (*FireStore) CreatePlan

func (s *FireStore) CreatePlan(ctx context.Context, p *lib.Plan, user *models.User) (id string, revID string, err error)

CreatePlan creates a plan from the plan and plan revision, and returns its new id and revision ID

func (*FireStore) CreatePlanRevision

func (s *FireStore) CreatePlanRevision(ctx context.Context, id string, p *lib.Plan, user *models.User) (string, error)

CreatePlanRevision creates a new revision for the plan, returning its ID

func (*FireStore) CreatePractices

func (s *FireStore) CreatePractices(ctx context.Context, version string, practices []lib.Practice) error

CreatePractices creates or replaces the practices at the specified version

func (*FireStore) CreateProject

func (s *FireStore) CreateProject(ctx context.Context, p *models.ProjectDetails) (string, error)

CreateProject creates a project and returns its new id

func (*FireStore) DeletePlan

func (s *FireStore) DeletePlan(ctx context.Context, id string) error

DeletePlan atomically deletes the specified plan, all of its revisions, and references in any projects

func (*FireStore) DeletePractices

func (s *FireStore) DeletePractices(ctx context.Context, version string) error

DeletePractices removes the practices at the specified version. This will break any plans that used this version!

func (*FireStore) DeleteProject

func (s *FireStore) DeleteProject(ctx context.Context, id string) error

DeleteProject deletes the specified project

func (*FireStore) GetConfigString

func (s *FireStore) GetConfigString(ctx context.Context, field string) (string, error)

GetConfigString returns the named configuration string

func (*FireStore) GetPlan

func (s *FireStore) GetPlan(ctx context.Context, id string) (*models.Plan, bool, error)

GetPlan returns the plan with the specified ID or false if it can't be found

func (*FireStore) GetPlanRevision

func (s *FireStore) GetPlanRevision(ctx context.Context, planID string, revID string) (*lib.Plan, bool, error)

GetPlanRevision returns the plan revision with the specified ID or false if it can't be found

func (*FireStore) GetPlanVersions

func (s *FireStore) GetPlanVersions(ctx context.Context, id string) ([]*models.RevisionVersion, error)

GetPlanVersions returns the versions of the specified plan, in date order earliest to latest

func (*FireStore) GetPractices

func (s *FireStore) GetPractices(ctx context.Context, version string) ([]lib.Practice, error)

GetPractices retrieves the specified version of the practice definitions

func (*FireStore) GetProject

func (s *FireStore) GetProject(ctx context.Context, id string) (*models.Project, bool, error)

GetProject returns the project with the specified ID and true, or false if it can't be found

func (*FireStore) GetUserData

func (s *FireStore) GetUserData(ctx context.Context, user *models.User) error

GetUserData extends the referenced user with any additional data recorded in the store

func (*FireStore) ListPlanRevisionIDs

func (s *FireStore) ListPlanRevisionIDs(ctx context.Context, id string) ([]string, error)

ListPlanRevisionIDs returns the revision ids of the specified plan, in date order earliest to latest or an error if it can't be found

func (*FireStore) ListPracticesVersions

func (s *FireStore) ListPracticesVersions(ctx context.Context) ([]string, error)

ListPracticesVersions lists all of the recorded versions of practice definitions, in lexicographic order

func (*FireStore) ListProjects

func (s *FireStore) ListProjects(ctx context.Context) ([]*models.Project, error)

ListProjects returns all of the projects

func (*FireStore) SaveUserData

func (s *FireStore) SaveUserData(ctx context.Context, user *models.User) error

SaveUserData records the user's LocalData, or removes it if user.LocalData==nil

func (*FireStore) SetManuallyAuthorized

func (s *FireStore) SetManuallyAuthorized(ctx context.Context, UID string, value bool) error

SetManuallyAuthorized sets this user's ManuallyAuthorized attribute

func (*FireStore) UpdateProject

func (s *FireStore) UpdateProject(ctx context.Context, id string, p *models.ProjectDetails) error

UpdateProject replaces a project with with the contents of the project struct (ctx context.Contextthe ID in the struct is ignored)

func (*FireStore) UserCreationAlertSent

func (s *FireStore) UserCreationAlertSent(ctx context.Context, UID string) error

UserCreationAlertSent sets this user's CreationAlertSent to true

type Store

type Store interface {
	// ListProjects returns all of the projects
	ListProjects(ctx context.Context) ([]*models.Project, error)
	// GetProject returns the project with the specified ID, or false if it can't be found
	GetProject(ctx context.Context, id string) (*models.Project, bool, error)
	// UpdateProject replaces a project with with the contents of the project struct (ctx context.Contextthe ID in the struct is ignored)
	UpdateProject(ctx context.Context, id string, p *models.ProjectDetails) error
	// CreateProject creates a project and returns its new id
	CreateProject(ctx context.Context, p *models.ProjectDetails) (string, error)
	// DeleteProject deletes the specified project
	DeleteProject(ctx context.Context, id string) error

	// GetPlan returns the plan with the specified ID and true, or (nil,false) if it can't be found
	GetPlan(ctx context.Context, id string) (*models.Plan, bool, error)
	// CreatePlan creates a plan and returns its new id and revision ID
	CreatePlan(ctx context.Context, p *lib.Plan, user *models.User) (id string, revID string, err error)
	// DeletePlanAndRevisions deletes the specified plan and all of its revisions
	DeletePlan(ctx context.Context, id string) error
	// CreatePlanRevision creates a new revision for the plan, returning its ID
	CreatePlanRevision(ctx context.Context, id string, p *lib.Plan, user *models.User) (string, error)
	// GetPlanRevision returns the plan revision with the specified ID or false if it can't be found
	GetPlanRevision(ctx context.Context, planID string, revID string) (*lib.Plan, bool, error)
	// ListPlanRevisionIDs returns the revision ids of the specified plan, in date order earliest to latest or an error if it can't be found
	ListPlanRevisionIDs(ctx context.Context, id string) ([]string, error)
	// GetPlanVersions returns the versions of the specified plan, in date order earliest to latest
	GetPlanVersions(ctx context.Context, id string) ([]*models.RevisionVersion, error)

	// GetUserData extends the referenced user with any additional data recorded in the store
	GetUserData(ctx context.Context, user *models.User) error
	// SaveUserData records the user's LocalData, or removes it if user.LocalData==nil
	SaveUserData(ctx context.Context, user *models.User) error
	// UserCreationAlertSent sets this user's CreationAlertSent to true
	UserCreationAlertSent(ctx context.Context, UID string) error
	// SetManuallyAuthorized sets this user's ManuallyAuthorized attribute
	SetManuallyAuthorized(ctx context.Context, UID string, value bool) error

	// GetConfigString returns the named configuration string
	GetConfigString(ctx context.Context, field string) (string, error)

	// ListPracticesVersions lists all of the recorded versions of practice definitions, in lexicographic order
	ListPracticesVersions(ctx context.Context) ([]string, error)
	// GetPractices retrieves the specified version of the practice definitions
	GetPractices(ctx context.Context, version string) ([]lib.Practice, error)
	// CreatePractices creates or replaces the practices at the specified version
	CreatePractices(ctx context.Context, version string, practices []lib.Practice) error
	// DeletePractices removes the practices at the specified version. This will break any plans that used this version!
	DeletePractices(ctx context.Context, version string) error
}

Store abstracts over different possible persistence implementations (there used to be more than one)

Jump to

Keyboard shortcuts

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