storage

package
v0.0.0-...-ac14b69 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 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

user_id, name i.e key need to be unique

func (*AccountRepository) Delete

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

Deletes a credential based on three fields user_id, entity and key (unique)

func (*AccountRepository) List

func (r *AccountRepository) List(
	ctx context.Context,
	offset, limit int,
	userId, accType 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, orgID 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, orgID string,
) ([]types.Study, error)

GetStudies returns a paginated list of studies based on an offset and limit

func (*StudyRepository) GetStudyBySlug

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

GetStudyBySlug fetches a study by using the slug

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, orgID string,
) ([]types.SegmentsProgress, error)

GetByStudySlug fetches the segment progress from the adopt_reports table by the study slug

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)

func (*UserRepository) GetUserOrgIDs

func (r *UserRepository) GetUserOrgIDs(
	ctx context.Context,
	userID string,
) ([]types.Org, error)

GetUserOrgID returns a users org id based on their user id

Jump to

Keyboard shortcuts

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