store

package
v0.0.87 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Db is the main databse connection
	Db   *gorm.DB
	Dbx  *sqlx.DB
	Conn database.Connection

	// DropAll signifies to drop all tables and recreate them
	DropAll = false
)

Functions

func CleanupTasks

func CleanupTasks() (err error)

CleanupTasks cleans up the db

func InitDB

func InitDB()

InitDB initializes the database

func Loop

func Loop()

Loop loops interval functions

func RemoveOld

func RemoveOld(table, conn, schemaName, tableName, columnName string) (err error)

RemoveOld removes old non-existent tables/columns

func Sync

func Sync(table string, obj interface{}, fields ...string) (err error)

Sync syncs to the store

Types

type Headers

type Headers []string

func (*Headers) Scan

func (h *Headers) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (Headers) Value

func (h Headers) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Job

type Job struct {
	ID       string  `json:"id" gorm:"primaryKey"`
	Type     string  `json:"type" gorm:"index:idx_job_type"`
	Request  g.Map   `json:"request" gorm:"type:json default '{}'"`
	Time     int64   `json:"time" gorm:"index:idx_job_time"`
	Duration float64 `json:"duration"`
	// Status    sling.ExecStatus `json:"status"`
	Err       string    `json:"err"`
	Result    g.Map     `json:"result" gorm:"type:json default '{}'"`
	UpdatedDt time.Time `json:"updated_dt" gorm:"autoUpdateTime"`

	Context g.Context `json:"-" gorm:"-"`
	// Task    *sling.TaskExecution `json:"-" gorm:"-"`
	Wait bool          `json:"wait" gorm:"-"`
	Done chan struct{} `json:"-" gorm:"-"`
}

Job represents a job

type QueryStatus

type QueryStatus string
const QueryStatusCancelled QueryStatus = "cancelled"
const QueryStatusCompleted QueryStatus = "completed"
const QueryStatusErrored QueryStatus = "errored"
const QueryStatusFetched QueryStatus = "fetched"
const QueryStatusSubmitted QueryStatus = "submitted"

type Row

type Row []interface{}

func (*Row) Scan

func (r *Row) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (Row) Value

func (r Row) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Rows

type Rows [][]interface{}

func (*Rows) Scan

func (r *Rows) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (Rows) Value

func (r Rows) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type SchemaTable

type SchemaTable struct {
	Connection string    `json:"connection" gorm:"primaryKey"`
	Database   string    `json:"database"  gorm:"primaryKey"`
	SchemaName string    `json:"schema_name" gorm:"primaryKey"`
	TableName  string    `json:"table_name" gorm:"primaryKey"`
	IsView     bool      `json:"is_view"`
	NumRows    int64     `json:"num_rows"`
	UpdatedDt  time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

SchemaTable represent a schema table/view

type Session

type Session struct {
	Name      string    `json:"name" gorm:"primaryKey"`
	Data      g.Map     `json:"data" gorm:"type:json not null default '{}'"`
	CreatedDt time.Time `json:"created_dt" gorm:"autoCreateTime"`
	UpdatedDt time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

Session represents a connection session

type TableColumn

type TableColumn struct {
	Connection  string    `json:"connection" gorm:"primaryKey"`
	Database    string    `json:"database"  gorm:"primaryKey"`
	SchemaName  string    `json:"schema_name" gorm:"primaryKey"`
	TableName   string    `json:"table_name" gorm:"primaryKey"`
	TableIsView bool      `json:"table_is_view"`
	Name        string    `json:"column_name" gorm:"primaryKey"`
	ID          int       `json:"column_id"`
	Type        string    `json:"column_type"`
	Precision   int       `json:"column_precision"`
	Scale       int       `json:"column_scale"`
	UpdatedDt   time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

TableColumn is a table/view column

type TableColumnStats

type TableColumnStats struct {
	Connection   string    `json:"connection" gorm:"primaryKey"`
	Database     string    `json:"database"  gorm:"primaryKey"`
	SchemaName   string    `json:"schema_name" gorm:"primaryKey"`
	TableName    string    `json:"table_name" gorm:"primaryKey"`
	ColumnName   string    `json:"column_name" gorm:"primaryKey"`
	NumRows      int64     `json:"num_rows"`
	NumValues    int64     `json:"num_values"`
	NumDistinct  int64     `json:"num_distinct"`
	NumNulls     int64     `json:"num_nulls"`
	MinLen       int       `json:"min_len"`
	MaxLen       int       `json:"max_len"`
	LastAnalyzed time.Time `json:"last_analyzed"`
	UpdatedDt    time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

TableColumnStats is a table/view column statistics record is separate from TableColumn to keep analysis values when hard refreshing

Jump to

Keyboard shortcuts

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