postgres

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DEFAULT_MAX_RESULT_SIZE = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetModel

type AssetModel struct {
	ID          string     `db:"id"`
	URN         string     `db:"urn"`
	Type        string     `db:"type"`
	Name        string     `db:"name"`
	Service     string     `db:"service"`
	Description string     `db:"description"`
	Data        JSONMap    `db:"data"`
	URL         string     `db:"url"`
	Labels      JSONMap    `db:"labels"`
	IsDeleted   bool       `db:"is_deleted"`
	Version     string     `db:"version"`
	UpdatedBy   UserModel  `db:"updated_by"`
	CreatedAt   time.Time  `db:"created_at"`
	UpdatedAt   time.Time  `db:"updated_at"`
	RefreshedAt *time.Time `db:"refreshed_at"`
	// version specific information
	Changelog types.JSONText `db:"changelog"`
	Owners    types.JSONText `db:"owners"`
}

type AssetProbeModel

type AssetProbeModel struct {
	ID           string    `db:"id"`
	AssetURN     string    `db:"asset_urn"`
	Status       string    `db:"status"`
	StatusReason string    `db:"status_reason"`
	Metadata     JSONMap   `db:"metadata"`
	Timestamp    time.Time `db:"timestamp"`
	CreatedAt    time.Time `db:"created_at"`
}

type AssetRepository

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

AssetRepository is a type that manages user operation to the primary database

func NewAssetRepository

func NewAssetRepository(
	c *Client,
	userRepo *UserRepository,
	cfg AssetRepositoryConfig,
) (*AssetRepository, error)

NewAssetRepository initializes user repository clients

func (*AssetRepository) AddProbe

func (r *AssetRepository) AddProbe(ctx context.Context, assetURN string, probe *asset.Probe) error

func (*AssetRepository) BuildFilterQuery

func (r *AssetRepository) BuildFilterQuery(builder sq.SelectBuilder, flt asset.Filter) sq.SelectBuilder

BuildFilterQuery retrieves the sql query based on applied filter in the queryString

func (*AssetRepository) DeleteByID

func (r *AssetRepository) DeleteByID(ctx context.Context, id string) (urn string, err error)

DeleteByID hard delete asset using its ID

func (*AssetRepository) DeleteByIsDeletedAndServicesAndUpdatedAt added in v0.9.1

func (r *AssetRepository) DeleteByIsDeletedAndServicesAndUpdatedAt(
	ctx context.Context,
	isDeleted bool,
	services []string,
	thresholdTime time.Time,
) (urns []string, err error)

func (*AssetRepository) DeleteByQueryExpr added in v0.7.8

func (r *AssetRepository) DeleteByQueryExpr(ctx context.Context, queryExpr queryexpr.ExprStr) ([]string, error)

func (*AssetRepository) DeleteByURN

func (r *AssetRepository) DeleteByURN(ctx context.Context, urn string) error

DeleteByURN hard delete asset using its URN

func (*AssetRepository) GetAll

func (r *AssetRepository) GetAll(ctx context.Context, flt asset.Filter) ([]asset.Asset, error)

GetAll retrieves list of assets with filters

func (*AssetRepository) GetByID

func (r *AssetRepository) GetByID(ctx context.Context, id string) (asset.Asset, error)

GetByID retrieves asset by its ID

func (*AssetRepository) GetByIDWithTx added in v0.9.0

func (r *AssetRepository) GetByIDWithTx(ctx context.Context, tx *sqlx.Tx, id string) (asset.Asset, error)

GetByIDWithTx retrieves asset by its ID with Transaction

func (*AssetRepository) GetByURN

func (r *AssetRepository) GetByURN(ctx context.Context, urn string) (asset.Asset, error)

func (*AssetRepository) GetByURNWithTx added in v0.8.1

func (r *AssetRepository) GetByURNWithTx(ctx context.Context, tx *sqlx.Tx, urn string) (asset.Asset, error)

func (*AssetRepository) GetByVersionWithID

func (r *AssetRepository) GetByVersionWithID(ctx context.Context, id, version string) (asset.Asset, error)

GetByVersionWithID retrieves the specific asset version

func (*AssetRepository) GetByVersionWithURN

func (r *AssetRepository) GetByVersionWithURN(ctx context.Context, urn, version string) (asset.Asset, error)

func (*AssetRepository) GetCount

func (r *AssetRepository) GetCount(ctx context.Context, flt asset.Filter) (int, error)

GetCount retrieves number of assets for every type

func (*AssetRepository) GetCountByIsDeletedAndServicesAndUpdatedAt added in v0.9.1

func (r *AssetRepository) GetCountByIsDeletedAndServicesAndUpdatedAt(
	ctx context.Context,
	isDeleted bool,
	services []string,
	thresholdTime time.Time,
) (uint32, error)

GetCountByIsDeletedAndServicesAndUpdatedAt retrieves number of assets based on IsDeleted, Services, and UpdatedAt

func (*AssetRepository) GetCountByQueryExpr added in v0.7.8

func (r *AssetRepository) GetCountByQueryExpr(ctx context.Context, queryExpr queryexpr.ExprStr) (uint32, error)

GetCountByQueryExpr retrieves number of assets for every type based on query expr

func (*AssetRepository) GetProbes

func (r *AssetRepository) GetProbes(ctx context.Context, assetURN string) ([]asset.Probe, error)

func (*AssetRepository) GetProbesWithFilter

func (r *AssetRepository) GetProbesWithFilter(ctx context.Context, flt asset.ProbesFilter) (map[string][]asset.Probe, error)

func (*AssetRepository) GetTypes

func (r *AssetRepository) GetTypes(ctx context.Context, flt asset.Filter) (map[asset.Type]int, error)

GetTypes fetches types with assets count for all available types and returns them as a map[typeName]count

func (*AssetRepository) GetVersionHistory

func (r *AssetRepository) GetVersionHistory(ctx context.Context, flt asset.Filter, id string, excludedChangelogPaths []string) ([]asset.Asset, error)

GetVersionHistory retrieves the versions of an asset

func (*AssetRepository) SoftDeleteByID added in v0.9.0

func (r *AssetRepository) SoftDeleteByID(
	ctx context.Context,
	executedAt time.Time,
	id, updatedByID string,
) (urn, newVersion string, err error)

func (*AssetRepository) SoftDeleteByQueryExpr added in v0.9.0

func (r *AssetRepository) SoftDeleteByQueryExpr(
	ctx context.Context,
	executedAt time.Time,
	updatedByID string,
	queryExpr queryexpr.ExprStr,
) ([]asset.Asset, error)

func (*AssetRepository) SoftDeleteByURN added in v0.9.0

func (r *AssetRepository) SoftDeleteByURN(ctx context.Context, executedAt time.Time, urn, updatedByID string) (newVersion string, err error)

func (*AssetRepository) Upsert

func (r *AssetRepository) Upsert(
	ctx context.Context,
	ast *asset.Asset,
	isUpdateOnly bool,
	assetConfig asset.Config,
) (upsertedAsset *asset.Asset, columnLineageProducer asset.ColumnLineageProducer, err error)

Upsert creates a new asset if it does not exist yet. It updates if asset does exist. Checking existence is done using "urn", "type", "name", "data", and "service" fields.

func (*AssetRepository) UpsertPatch added in v0.8.1

func (r *AssetRepository) UpsertPatch(
	ctx context.Context,
	ast *asset.Asset,
	patchData map[string]interface{},
	isUpdateOnly bool,
	assetConfig asset.Config,
) (upsertedAsset *asset.Asset, columnLineageProducer asset.ColumnLineageProducer, err error)

UpsertPatch creates a new asset if it does not exist yet. It updates if asset does exist. Checking existence is done using "urn", "type", and "service" fields And will revalidate again with additional: "data" and "name" fields.

type AssetRepositoryConfig added in v0.10.3

type AssetRepositoryConfig struct {
	DefaultGetMaxSize   int
	DefaultUserProvider string
	Logger              log.Logger
	LineageParserClient asset.LineageParserClient
}

AssetRepositoryConfig holds configuration for AssetRepository.

type Client

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

func NewClient

func NewClient(ctx context.Context, cfg Config) (*Client, error)

NewClient initializes database connection

func NewClientWithDB added in v0.6.0

func NewClientWithDB(db *sql.DB) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) ExecQueries

func (c *Client) ExecQueries(ctx context.Context, queries []string) error

ExecQueries is used for executing list of db query

func (*Client) Migrate

func (c *Client) Migrate() (err error)

func (*Client) RunWithinTx

func (c *Client) RunWithinTx(ctx context.Context, f func(tx *sqlx.Tx) error) error

type Config

type Config struct {
	Host     string `mapstructure:"host" default:"localhost"`
	Port     int    `mapstructure:"port" default:"5432"`
	Name     string `mapstructure:"name" default:"postgres"`
	User     string `mapstructure:"user" default:"root"`
	Password string `mapstructure:"password" default:""`
	SSLMode  string `mapstructure:"sslmode" default:"disable"`
}

func (*Config) ConnectionURL

func (c *Config) ConnectionURL() *url.URL

ConnectionURL

type DiscussionModel

type DiscussionModel struct {
	ID        string         `db:"id"`
	Title     string         `db:"title"`
	Body      string         `db:"body"`
	Type      string         `db:"type"`
	State     string         `db:"state"`
	Owner     UserModel      `db:"owner"`
	Labels    pq.StringArray `db:"labels"`
	Assets    pq.StringArray `db:"assets"`
	Assignees pq.StringArray `db:"assignees"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
}

type DiscussionRepository

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

DiscussionRepository is a type that manages discussion operation to the primary database

func NewDiscussionRepository

func NewDiscussionRepository(c *Client, defaultGetMaxSize int) (*DiscussionRepository, error)

NewDiscussionRepository initializes discussion repository clients

func (*DiscussionRepository) Create

Create inserts a new discussion data

func (*DiscussionRepository) CreateComment

func (r *DiscussionRepository) CreateComment(ctx context.Context, cmt *discussion.Comment) (string, error)

Create adds a new comment to a specific discussion

func (*DiscussionRepository) DeleteComment

func (r *DiscussionRepository) DeleteComment(ctx context.Context, cid, did string) error

Delete removes a comment

func (*DiscussionRepository) Get

Get returns a specific discussion by id

func (*DiscussionRepository) GetAll

GetAll fetchs all discussion data

func (*DiscussionRepository) GetAllComments

func (r *DiscussionRepository) GetAllComments(ctx context.Context, did string, flt discussion.Filter) ([]discussion.Comment, error)

GetAll fetches all comments of a specific discussion

func (*DiscussionRepository) GetComment

func (r *DiscussionRepository) GetComment(ctx context.Context, cid, did string) (discussion.Comment, error)

Get fetchs a comment

func (*DiscussionRepository) Patch

Patch will update a field in discussion

func (*DiscussionRepository) UpdateComment

func (r *DiscussionRepository) UpdateComment(ctx context.Context, cmt *discussion.Comment) error

Update updates a comment

type JSONMap

type JSONMap map[string]interface{}

func (JSONMap) MarshalJSON

func (m JSONMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONMap) Scan

func (m *JSONMap) Scan(value interface{}) error

func (*JSONMap) UnmarshalJSON

func (m *JSONMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

type LineageEdgeModel

type LineageEdgeModel struct {
	Source       string  `db:"source"`
	SourceColumn string  `db:"source_column"`
	Target       string  `db:"target"`
	TargetColumn string  `db:"target_column"`
	Prop         JSONMap `db:"prop"`
}

type LineageGraphModel

type LineageGraphModel []LineageEdgeModel

type LineageRepository

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

func NewLineageRepository

func NewLineageRepository(client *Client) (*LineageRepository, error)

NewLineageRepository initializes lineage repository

func (*LineageRepository) DeleteByURN added in v0.5.3

func (repo *LineageRepository) DeleteByURN(ctx context.Context, urn string) error

func (*LineageRepository) DeleteByURNs added in v0.7.8

func (repo *LineageRepository) DeleteByURNs(ctx context.Context, urns []string) error

func (*LineageRepository) GetColumnGraph added in v0.10.0

func (repo *LineageRepository) GetColumnGraph(ctx context.Context, urn string, query asset.LineageQuery) (asset.LineageGraph, error)

GetColumnGraph returns a graph that contains list of relations of a given node at column level

func (*LineageRepository) GetGraph

func (repo *LineageRepository) GetGraph(ctx context.Context, urn string, query asset.LineageQuery) (asset.LineageGraph, error)

GetGraph returns a graph that contains list of relations of a given node

func (*LineageRepository) InsertColumnGraph added in v0.10.0

func (repo *LineageRepository) InsertColumnGraph(ctx context.Context, graph asset.LineageGraph) error

InsertColumnGraph inserts column level lineage graph into the database for testing purpose as of now

func (*LineageRepository) SoftDeleteByURN added in v0.9.0

func (repo *LineageRepository) SoftDeleteByURN(ctx context.Context, urn string) error

func (*LineageRepository) SoftDeleteByURNs added in v0.9.0

func (repo *LineageRepository) SoftDeleteByURNs(ctx context.Context, urns []string) error

func (*LineageRepository) Upsert

func (repo *LineageRepository) Upsert(ctx context.Context, urn string, upstreams, downstreams []string) error

Upsert insert or delete connections of a given node by comparing them with current state

func (*LineageRepository) UpsertColumnLineage added in v0.10.3

func (repo *LineageRepository) UpsertColumnLineage(ctx context.Context, assetURN string, newEdges asset.LineageGraph) error

type StarClauses

type StarClauses struct {
	Limit            int
	Offset           int
	SortKey          string
	SortDirectionKey string
}

type StarRepository

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

StarRepository is a type that manages star operation to the primary database

func NewStarRepository

func NewStarRepository(c *Client) (*StarRepository, error)

NewStarRepository initializes star repository clients

func (*StarRepository) Create

func (r *StarRepository) Create(ctx context.Context, userID, assetID string) (string, error)

Create insert a new record in the stars table

func (*StarRepository) Delete

func (r *StarRepository) Delete(ctx context.Context, userID, assetID string) error

Delete will delete/unstar a starred asset for a user id

func (*StarRepository) GetAllAssetsByUserID

func (r *StarRepository) GetAllAssetsByUserID(ctx context.Context, flt star.Filter, userID string) ([]asset.Asset, error)

GetAllAssetsByUserID fetch list of assets starred by a user

func (*StarRepository) GetAssetByUserID

func (r *StarRepository) GetAssetByUserID(ctx context.Context, userID, assetID string) (asset.Asset, error)

GetAssetByUserID fetch a specific starred asset by user id

func (*StarRepository) GetStargazers

func (r *StarRepository) GetStargazers(ctx context.Context, flt star.Filter, assetID string) ([]user.User, error)

GetStargazers fetch list of user IDs that star an asset

type TagJoinTemplateFieldModel

type TagJoinTemplateFieldModel struct {
	Template TagTemplateModel      `db:"tag_templates"`
	Field    TagTemplateFieldModel `db:"tag_template_fields"`
}

TagJoinTemplateFieldModel is a placeholder for joined template and field

type TagJoinTemplateFieldModels

type TagJoinTemplateFieldModels []TagJoinTemplateFieldModel

TagJoinTemplateFieldModels is a slice of placeholder for joined template and field

type TagJoinTemplateTagFieldModel

type TagJoinTemplateTagFieldModel struct {
	Template TagTemplateModel      `db:"tag_templates"`
	Tag      TagModel              `db:"tags"`
	Field    TagTemplateFieldModel `db:"tag_template_fields"`
}

TemplateField is a placeholder for joined template, tag, and field

type TagJoinTemplateTagFieldModels

type TagJoinTemplateTagFieldModels []TagJoinTemplateTagFieldModel

TagJoinTemplateTagFieldModels is a slice of placeholder for joined template, tag, and field

type TagModel

type TagModel struct {
	ID        uint                  `db:"id"`
	Value     string                `db:"value"`
	AssetID   string                `db:"asset_id"`
	FieldID   uint                  `db:"field_id"`
	CreatedAt time.Time             `db:"created_at"`
	UpdatedAt time.Time             `db:"updated_at"`
	Field     TagTemplateFieldModel `db:"-"`
}

TagModel is a model for tag value in database table

type TagModels

type TagModels []TagModel

type TagRepository

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

TagRepository is a type that manages tag operation ot the primary database

func NewTagRepository

func NewTagRepository(client *Client) (*TagRepository, error)

NewTagRepository initializes tag repository all methods in tag repository uses passed by reference which will mutate the reference variable in method's argument

func (*TagRepository) Create

func (r *TagRepository) Create(ctx context.Context, domainTag *tag.Tag) error

Create inserts tag to database

func (*TagRepository) Delete

func (r *TagRepository) Delete(ctx context.Context, domainTag tag.Tag) error

Delete deletes tags from database

func (*TagRepository) Read

func (r *TagRepository) Read(ctx context.Context, filter tag.Tag) ([]tag.Tag, error)

Read reads tags grouped by its template

func (*TagRepository) Update

func (r *TagRepository) Update(ctx context.Context, domainTag *tag.Tag) error

Update updates tags in the database

type TagTemplateFieldModel

type TagTemplateFieldModel struct {
	ID          uint             `db:"id"`
	URN         string           `db:"urn"`
	DisplayName string           `db:"display_name"`
	Description string           `db:"description"`
	DataType    string           `db:"data_type"`
	Options     *string          `db:"options"`
	Required    bool             `db:"required"`
	TemplateURN string           `db:"template_urn"`
	CreatedAt   time.Time        `db:"created_at"`
	UpdatedAt   time.Time        `db:"updated_at"`
	Template    TagTemplateModel `db:"-"`
}

TagTemplateFieldModel is a model for field tag in database table

type TagTemplateFieldModels

type TagTemplateFieldModels []TagTemplateFieldModel

type TagTemplateModel

type TagTemplateModel struct {
	URN         string                 `db:"urn"`
	DisplayName string                 `db:"display_name"`
	Description string                 `db:"description"`
	CreatedAt   time.Time              `db:"created_at"`
	UpdatedAt   time.Time              `db:"updated_at"`
	Fields      TagTemplateFieldModels `db:"-"`
}

TagTemplateModel is a model for template database table

type TagTemplateModels

type TagTemplateModels []TagTemplateModel

type TagTemplateRepository

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

TagTemplateRepository is a type that manages template operation to the primary database

func NewTagTemplateRepository

func NewTagTemplateRepository(c *Client) (*TagTemplateRepository, error)

NewTagTemplateRepository initializes template repository clients all methods in template repository uses passed by reference which will mutate the reference variable in method's argument

func (*TagTemplateRepository) Create

func (r *TagTemplateRepository) Create(ctx context.Context, templateDomain *tag.Template) error

Create inserts template to database

func (*TagTemplateRepository) Delete

func (r *TagTemplateRepository) Delete(ctx context.Context, templateURN string) error

Delete deletes template and its fields from database

func (*TagTemplateRepository) Read

func (r *TagTemplateRepository) Read(ctx context.Context, templateURN string) ([]tag.Template, error)

Read reads template from database by URN

func (*TagTemplateRepository) ReadAll

func (r *TagTemplateRepository) ReadAll(ctx context.Context) ([]tag.Template, error)

Read reads all template from database

func (*TagTemplateRepository) Update

func (r *TagTemplateRepository) Update(ctx context.Context, targetURN string, templateDomain *tag.Template) error

Update updates template into database

type UserModel

type UserModel struct {
	ID        sql.NullString `db:"id"`
	Email     sql.NullString `db:"email"`
	Provider  sql.NullString `db:"provider"`
	CreatedAt sql.NullTime   `db:"created_at"`
	UpdatedAt sql.NullTime   `db:"updated_at"`
}

type UserModels

type UserModels []UserModel

type UserRepository

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

UserRepository is a type that manages user operation to the primary database

func NewUserRepository

func NewUserRepository(c *Client) (*UserRepository, error)

NewUserRepository initializes user repository clients

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, ud *user.User) (string, error)

Create insert a user to the database returns error if email is empty

func (*UserRepository) CreateWithTx

func (r *UserRepository) CreateWithTx(ctx context.Context, tx *sqlx.Tx, ud *user.User) (string, error)

Create insert a user to the database using given transaction as client

func (*UserRepository) GetByEmail

func (r *UserRepository) GetByEmail(ctx context.Context, email string) (user.User, error)

GetByEmail retrieves user by given the email

func (*UserRepository) GetByEmailWithTx added in v0.5.2

func (r *UserRepository) GetByEmailWithTx(ctx context.Context, querier sqlx.QueryerContext, email string) (user.User, error)

func (*UserRepository) GetOrInsertByEmail added in v0.7.11

func (r *UserRepository) GetOrInsertByEmail(ctx context.Context, ud *user.User) (string, error)

func (*UserRepository) InsertByEmail added in v0.7.11

func (r *UserRepository) InsertByEmail(ctx context.Context, ud *user.User) (string, error)

InsertByEmail insert a new row if email not found

Jump to

Keyboard shortcuts

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