databaseStore

package
v0.0.0-...-27c9e6d Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectScan

func SelectScan(rows, functionResults *sql.Rows, page, size, totalRows int) (map[string]interface{}, error)

Types

type ConditionGroup

type ConditionGroup struct {
	Key      string      `json:"key"`
	Operator string      `json:"operator"`
	Value    interface{} `json:"value"`
	// ConditionGroup is a field that has one of this fields inside itself: [key, operator, value] nor [filterSet, conjunction]
	FilterSet   []ConditionGroup `json:"filterSet"`
	Conjunction string           `json:"conjunction,omitempty" binding:"oneof='and' 'or' ''"`
}

type DatabaseStore

type DatabaseStore interface {
	AddTable(ctx context.Context, db *dbPkg.DB, accountId string, projectName string, tableName string, isPublic, isWritePublic bool) error
	DeleteTable(ctx context.Context, accountId string, projectName string, tableName string) error
	IsTablePublic(ctx context.Context, projectTag string, tableName string) (bool, error)
	IsWriteToTablePublic(ctx context.Context, projectTag string, tableName string) (bool, error)
	SetTableAccess(ctx context.Context, accountId, projectName, tableName string, isPublic bool) error
	SetWriteToTableAccess(ctx context.Context, accountId, projectName, tableName string, isWritePublic bool) error
	AddTableColumn(ctx context.Context, db *dbPkg.DB, accountId string, projectName string, tableName string, columnName string, columnType string) error
	DeleteTableColumn(ctx context.Context, accountId string, projectName string, tableName string, columnName string) error
	GetTablesList(ctx context.Context, accountId string, projectName string) ([]string, error)
	ListTableColumns(ctx context.Context, accountId string, projectName string, tableName string) ([]models.PgColumn, error)
	RunDatabaseQuery(ctx context.Context, projectTag string, query string) (map[string]interface{}, error)

	DeleteDatabase(ctx context.Context, accountId string, projectName string) error
	DeleteDatabaseUser(ctx context.Context, accountId string, projectName string) error
	GetDatabaseUser(ctx context.Context, accountId string, projectName string) (models.DatabaseUser, error)

	InsertRow(ctx context.Context, projectTag string, tableName string, row map[string]interface{}) error
	UpdateRow(ctx context.Context, useRowLevelSecurity bool, tpAccountId, projectTag string, tableName string, id int, row map[string]interface{}) error
	DeleteRow(ctx context.Context, useRowLevelSecurity bool, tpAccountId, projectTag string, tableName string, id int, filters ConditionGroup) error
	SelectRows(ctx context.Context, useRowLevelSecurity bool, tpAccountId, projectTag string, tableName string, columns []string, functions []Function, filters ConditionGroup, orderBy string, descending bool, offset int, size int) (map[string]interface{}, error)
	SelectRowById(ctx context.Context, useRowLevelSecurity bool, tpAccountId, projectTag string, tableName string, id int) (map[string]interface{}, error)

	CreateViewsTable(db *dbPkg.DB) (err error)
	DeleteView(ctx context.Context, accountId string, projectName string, viewName string) error
	GetViewsList(ctx context.Context, accountId string, projectName string) ([]models.DatabaseView, error)
	GetViewDetails(ctx context.Context, accountId string, projectName string, viewName string) (models.DatabaseView, error)
	GetViewDetailsByProjectTag(ctx context.Context, projectTag string, viewName string) (models.DatabaseView, error)
	UpsertView(ctx context.Context, accountId string, projectName string, viewName string, tableName string, columns []string, filters ConditionGroup, jsonQuery map[string]interface{}, isPublic bool) error
	RunViewQuery(ctx context.Context, useRowLevelSecurity bool, tpAccountId, projectTag string, viewName string, offset int, limit int) (map[string]interface{}, error)
	IsViewPublic(ctx context.Context, projectTag string, viewName string) (bool, error)

	AddDatabaseJob(ctx context.Context, dbJob models.DatabaseJob) error
	SetDatabaseJobStatus(ctx context.Context, accountId, projectName, jobType, status string) error
	GetDatabaseJob(ctx context.Context, accountId string, projectName string) (models.DatabaseJob, error)
}

func New

func New(db *dbPkg.DB) DatabaseStore

type Function

type Function struct {
	Function string   `json:"function"`
	Columns  []string `json:"columns"`
}

Jump to

Keyboard shortcuts

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