storage

package
v0.0.0-...-d3ca574 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 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 AccountRepository

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

func NewAccountRepository

func NewAccountRepository(db *sql.DB) *AccountRepository

func (*AccountRepository) Create

func (r *AccountRepository) Create(
	ctx context.Context,
	a types.Account,
) error

Create creates a new account object in the database

Accounts Map to the Credentials table in the database in the following way:

Name -> entity (This is used as the "Source") ConnectedAccount.Credentials -> details AuthType -> key UserId -> user_id

user_id, entity, key need to be unique, therefore currently we will not allow more than one instance of an account Type i.e You can only connect one Fly Instance

func (*AccountRepository) Delete

func (r *AccountRepository) Delete(
	ctx context.Context,
	a types.Account,
) error

Delete will delete a credential based on its three unique fields user_id, entity and key

func (*AccountRepository) List

func (r *AccountRepository) List(
	ctx context.Context,
	offset, limit int,
	userId string,
) ([]types.Account, error)

List is used to pull credentials from the database and map them to an account

type Repositories

type Repositories struct {
	Db            *sql.DB
	Study         types.StudyRepository
	StudySegments types.StudySegmentsRepository
	User          types.UserRepository
	Account       types.AccountRepository
	StudyConf     types.StudyConfRepository
}

func InitializeRepositories

func InitializeRepositories(dbURI string) Repositories

type StudyConfRepository

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

func NewStudyConfRepository

func NewStudyConfRepository(db *sql.DB) *StudyConfRepository

func (*StudyConfRepository) Create

Create creates a new study_conf object in the database NOTE: Study Configs have no unique identifiers and this function will not have logic to check for duplicates

func (*StudyConfRepository) GetByStudySlug

func (r *StudyConfRepository) GetByStudySlug(
	ctx context.Context,
	slug, userID string,
) ([]*types.DatabaseStudyConf, error)

GetConfsByStudy will return all the latest unique confs that are attached to a study

type StudyRepository

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

func NewStudyRepository

func NewStudyRepository(db *sql.DB) *StudyRepository

NewStudyRepository returns a new instance of the Study Repository object to manage calls to the database

func (*StudyRepository) CreateStudy

func (r *StudyRepository) CreateStudy(
	ctx context.Context,
	name, userId string,
) (types.Study, error)

CreateStudy used to do the row creation in the database for the study objects

func (*StudyRepository) GetStudies

func (r *StudyRepository) GetStudies(ctx context.Context, offset int, limit int, userId string) ([]types.Study, error)

func (*StudyRepository) GetStudyBySlug

func (r *StudyRepository) GetStudyBySlug(
	ctx context.Context,
	slug, userId string,
) (types.Study, error)

type StudySegmentsRepository

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

func NewStudySegmentsRepository

func NewStudySegmentsRepository(db *sql.DB) *StudySegmentsRepository

func (*StudySegmentsRepository) GetByStudySlug

func (r *StudySegmentsRepository) GetByStudySlug(
	ctx context.Context,
	slug, userID string,
) ([]types.SegmentsProgress, error)

type UserRepository

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

func NewUserRepository

func NewUserRepository(db *sql.DB) *UserRepository

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, userID string) (types.User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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