Documentation ¶
Index ¶
- func ConnectENV() (*sql.DB, error)
- func ConnectENVWithOrg(orgId int) (*sql.DB, error)
- func ConnectRDS() (*sql.DB, error)
- func ConnectRDSWithOrg(orgId int) (*sql.DB, error)
- type DBTX
- type Queries
- func (q *Queries) AddFiles(ctx context.Context, files []pgdb.FileParams) ([]pgdb.File, error)
- func (q *Queries) AddFolder(ctx context.Context, r pgdb.PackageParams) (*pgdb.Package, error)
- func (q *Queries) AddPackages(ctx context.Context, records []pgdb.PackageParams) ([]pgdb.Package, error)
- func (q *Queries) GetByCognitoId(ctx context.Context, id string) (*pgdb.User, error)
- func (q *Queries) GetDatasetClaim(ctx context.Context, user *pgdb.User, datasetNodeId string, ...) (*dataset.Claim, error)
- func (q *Queries) GetDatasetStorageById(ctx context.Context, datasetId int64) (int64, error)
- func (q *Queries) GetDatasets(ctx context.Context, organizationId int) ([]pgdb.Dataset, error)
- func (q *Queries) GetFeatureFlags(ctx context.Context, organizationId int64) ([]pgdb.FeatureFlags, error)
- func (q *Queries) GetOrganization(ctx context.Context, id int64) (*pgdb.Organization, error)
- func (q *Queries) GetOrganizationClaim(ctx context.Context, userId int64, organizationId int64) (*organization.Claim, error)
- func (q *Queries) GetOrganizationStorageById(ctx context.Context, organizationId int64) (int64, error)
- func (q *Queries) GetOrganizationUserById(ctx context.Context, id int64) (*pgdb.OrganizationUser, error)
- func (q *Queries) GetPackageChildren(ctx context.Context, parent *pgdb.Package, datasetId int, onlyFolders bool) ([]pgdb.Package, error)
- func (q *Queries) GetPackageStorageById(ctx context.Context, packageId int64) (int64, error)
- func (q *Queries) GetTokenByCognitoId(ctx context.Context, id string) (*pgdb.Token, error)
- func (q *Queries) GetUserByCognitoId(ctx context.Context, id string) (*pgdb.User, error)
- func (q *Queries) IncrementDatasetStorage(ctx context.Context, datasetId int64, size int64) error
- func (q *Queries) IncrementOrganizationStorage(ctx context.Context, organizationId int64, size int64) error
- func (q *Queries) IncrementPackageStorage(ctx context.Context, packageId int64, size int64) error
- func (q *Queries) IncrementPackageStorageAncestors(ctx context.Context, parentId int64, size int64) error
- func (q *Queries) ShowSearchPath(loc string)
- func (q *Queries) UpdateBucketForFile(ctx context.Context, uploadId string, bucket string, s3Key string, ...) error
- func (q *Queries) WithOrg(orgId int) (*Queries, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type SQLStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectENV ¶
ConnectENV returns a DB instance. Used for testing, it requires the following environment variables to be set - POSTGRES_HOST - POSTGRES_PORT (will default to 5432 if missing) - POSTGRES_USER - POSTGRES_PASSWORD - PENNSIEVE_DB - POSTGRES_SSL_MODE (should be set to "disable" if the server is not https, left blank if it is)
func ConnectRDS ¶
ConnectRDS returns a DB instance. The Lambda function leverages IAM roles to gain access to the DB Proxy. The function does NOT set the search_path to the organization schema. Requires following LAMBDA ENV VARIABLES:
- RDS_PROXY_ENDPOINT
- REGION
- ENV
Types ¶
type DBTX ¶
type DBTX interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) PrepareContext(context.Context, string) (*sql.Stmt, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row }
DBTX Default interface with methods that are available for both DB adn TX sessions.
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
Queries is a struct with a db object that implements the DBTX interface. This means that db can either be a direct DB connection or a TX transaction.
func (*Queries) AddPackages ¶
func (q *Queries) AddPackages(ctx context.Context, records []pgdb.PackageParams) ([]pgdb.Package, error)
AddPackages adds packages to a dataset.
- This call should typically be wrapped in a Transaction as it will run multiple queries.
- Packages can be in different folders, but it is assumed that the folders already exist.
func (*Queries) GetByCognitoId ¶
GetByCognitoId returns a user from Postgress based on his/her cognito-id This function also returns the preferred org and whether the user is a super-admin.
func (*Queries) GetDatasetClaim ¶
func (q *Queries) GetDatasetClaim(ctx context.Context, user *pgdb.User, datasetNodeId string, organizationId int64) (*dataset.Claim, error)
GetDatasetClaim returns the highest role that the user has for a given dataset. This method checks the roles of the dataset, the teams, and the specific user roles.
func (*Queries) GetDatasetStorageById ¶
func (*Queries) GetDatasets ¶
GetDatasets returns all rows in the Upload Record Table
func (*Queries) GetFeatureFlags ¶
func (q *Queries) GetFeatureFlags(ctx context.Context, organizationId int64) ([]pgdb.FeatureFlags, error)
GetFeatureFlags returns all rows in the FeatureFlags Table
func (*Queries) GetOrganization ¶
GetOrganization returns a single organization
func (*Queries) GetOrganizationClaim ¶
func (q *Queries) GetOrganizationClaim(ctx context.Context, userId int64, organizationId int64) (*organization.Claim, error)
GetOrganizationClaim returns an organization claim for a specific user.
func (*Queries) GetOrganizationStorageById ¶
func (*Queries) GetOrganizationUserById ¶
func (*Queries) GetPackageChildren ¶
func (q *Queries) GetPackageChildren(ctx context.Context, parent *pgdb.Package, datasetId int, onlyFolders bool) ([]pgdb.Package, error)
GetPackageChildren Get the children in a package
func (*Queries) GetPackageStorageById ¶
func (*Queries) GetTokenByCognitoId ¶
GetTokenByCognitoId returns a user from Postgress based on his/her cognito-id This function also returns the preferred org and whether the user is a super-admin.
func (*Queries) GetUserByCognitoId ¶
GetUserByCognitoId returns a Pennsieve User based on the cognito id in the token pool.
func (*Queries) IncrementDatasetStorage ¶
IncrementDatasetStorage increases the storage associated with the provided dataset.
func (*Queries) IncrementOrganizationStorage ¶
func (q *Queries) IncrementOrganizationStorage(ctx context.Context, organizationId int64, size int64) error
IncrementOrganizationStorage increases the storage associated with the provided organization.
func (*Queries) IncrementPackageStorage ¶
IncrementPackageStorage increases the storage associated with the provided package.
func (*Queries) IncrementPackageStorageAncestors ¶
func (q *Queries) IncrementPackageStorageAncestors(ctx context.Context, parentId int64, size int64) error
IncrementPackageStorageAncestors increases the storage associated with the parents of the provided package.