Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.0.0-...-ca46253 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a requested record does not exist.

Functions

This section is empty.

Types

type Postgres

type Postgres struct {
	DSN      string `toml:"dsn"`
	Address  string `toml:"address"`
	User     string `toml:"user"`
	Password string `toml:"password"`
	Database string `toml:"database"`
	SSLMode  string `toml:"ssl_mode"`
	// contains filtered or unexported fields
}

Postgres is the d3d-api storage layer, replacing RethinkDB. The full repository surface (DAGs, history, shares, users, nodes, edges, menus) mirrors the method set previously implemented on top of RethinkDB.

Connection settings can be given either as a single `dsn` or as discrete fields (`address`, `user`, `password`, `database`, `ssl_mode`); the latter avoids URL-escaping passwords in templated configs. A non-empty DSN wins.

func (*Postgres) AddGroupMember

func (p *Postgres) AddGroupMember(gm models.GroupMember) error

func (*Postgres) AddMembership

func (p *Postgres) AddMembership(m models.Membership) error

func (*Postgres) AppendHistory

func (p *Postgres) AppendHistory(dagId, snapshotJSON, savedBy string) error

func (*Postgres) AppendImportedBy

func (p *Postgres) AppendImportedBy(id, username string) error

func (Postgres) Configured

func (p Postgres) Configured() bool

Configured reports whether any connection setting was provided.

func (*Postgres) CreateCompany

func (p *Postgres) CreateCompany(c models.Company) (string, error)

func (*Postgres) CreateDAG

func (p *Postgres) CreateDAG(dag models.Dag) (string, error)

func (*Postgres) CreateDAGs

func (p *Postgres) CreateDAGs(dags []models.Dag) (ids []string, err error)

func (*Postgres) CreateEdge

func (p *Postgres) CreateEdge(edge models.Edge) (string, error)

func (*Postgres) CreateEdges

func (p *Postgres) CreateEdges(edges []models.Edge) (ids []string, err error)

func (*Postgres) CreateElementShare

func (p *Postgres) CreateElementShare(s models.ElementShare) (string, error)

func (*Postgres) CreateGroup

func (p *Postgres) CreateGroup(g models.Group) (string, error)

func (*Postgres) CreateMenu

func (p *Postgres) CreateMenu(menu models.Menu) (string, error)

func (*Postgres) CreateMenus

func (p *Postgres) CreateMenus(menus []models.Menu) (ids []string, err error)

func (*Postgres) CreateNode

func (p *Postgres) CreateNode(node models.Node) (string, error)

func (*Postgres) CreateNodes

func (p *Postgres) CreateNodes(nodes []models.Node) (ids []string, err error)

func (*Postgres) CreateShare

func (p *Postgres) CreateShare(s models.Share) error

func (*Postgres) CreateUser

func (p *Postgres) CreateUser(u models.User) error

func (*Postgres) DeleteCompany

func (p *Postgres) DeleteCompany(id string) error

func (*Postgres) DeleteDAG

func (p *Postgres) DeleteDAG(id string) error

func (*Postgres) DeleteEdge

func (p *Postgres) DeleteEdge(id string) error

func (*Postgres) DeleteGroup

func (p *Postgres) DeleteGroup(id string) error

func (*Postgres) DeleteMenu

func (p *Postgres) DeleteMenu(id string) error

func (*Postgres) DeleteNode

func (p *Postgres) DeleteNode(id string) error

func (Postgres) EffectiveDSN

func (p Postgres) EffectiveDSN() string

EffectiveDSN returns the connection string the storage layer connects with: the configured DSN verbatim, a DSN assembled from the discrete fields, or the local development default when nothing is configured.

func (*Postgres) FindRelatedDAG

func (p *Postgres) FindRelatedDAG(dag models.Dag) (relatedDAG models.Dag, foundDAG bool, err error)

func (*Postgres) FindRelatedEdge

func (p *Postgres) FindRelatedEdge(edge models.Edge) (relatedEdge models.Edge, foundEdge bool, err error)

func (*Postgres) FindRelatedMenu

func (p *Postgres) FindRelatedMenu(menu models.Menu) (relatedMenu models.Menu, foundMenu bool, err error)

func (*Postgres) FindRelatedNode

func (p *Postgres) FindRelatedNode(node models.Node) (relatedNode models.Node, foundNode bool, err error)

func (*Postgres) GetCompany

func (p *Postgres) GetCompany(id string) (models.Company, error)

func (*Postgres) GetCompanyMembers

func (p *Postgres) GetCompanyMembers(companyId string) ([]string, error)

func (*Postgres) GetDAG

func (p *Postgres) GetDAG(id string) (dag models.Dag, err error)

func (*Postgres) GetDAGPublic

func (p *Postgres) GetDAGPublic(id string) (dag models.Dag, err error)

GetDAGPublic returns the DAG only when it is marked public; callers should treat any error as "not found or not public" to avoid leaking existence.

func (*Postgres) GetDAGsSummary

func (p *Postgres) GetDAGsSummary(queryArgs map[string][]string) (dagsSummary []map[string]interface{}, err error)

func (*Postgres) GetEdge

func (p *Postgres) GetEdge(id string) (edge models.Edge, err error)

func (*Postgres) GetEdgesSummary

func (p *Postgres) GetEdgesSummary(queryArgs map[string][]string) (edgesSummary []map[string]interface{}, err error)

func (*Postgres) GetElementShare

func (p *Postgres) GetElementShare(id string) (models.ElementShare, error)

func (*Postgres) GetElementShareByJti

func (p *Postgres) GetElementShareByJti(jti string) (models.ElementShare, error)

func (*Postgres) GetGroup

func (p *Postgres) GetGroup(id string) (models.Group, error)

func (*Postgres) GetGroupMembers

func (p *Postgres) GetGroupMembers(groupId string) ([]string, error)

func (*Postgres) GetHistory

func (p *Postgres) GetHistory(dagId string) ([]models.DagHistory, error)

func (*Postgres) GetMenu

func (p *Postgres) GetMenu(id string) (menu models.Menu, err error)

func (*Postgres) GetMenusOptions

func (p *Postgres) GetMenusOptions(queryArgs map[string][]string) (menusOptions map[string]models.Menu, err error)

func (*Postgres) GetMenusSummary

func (p *Postgres) GetMenusSummary(queryArgs map[string][]string) (menusSummary []map[string]interface{}, err error)

func (*Postgres) GetNode

func (p *Postgres) GetNode(id string) (node models.Node, err error)

func (*Postgres) GetNodesSummary

func (p *Postgres) GetNodesSummary(queryArgs map[string][]string) (nodesSummary []map[string]interface{}, err error)

func (*Postgres) GetShareByJti

func (p *Postgres) GetShareByJti(jti string) (models.Share, error)

func (*Postgres) GetUser

func (p *Postgres) GetUser(username string) (models.User, error)

func (*Postgres) GetUserCompanyIds

func (p *Postgres) GetUserCompanyIds(username string) ([]string, error)

GetUserCompanyIds returns all company IDs the user belongs to. Used for share audience resolution.

func (*Postgres) GetUserGroupIds

func (p *Postgres) GetUserGroupIds(username string) ([]string, error)

GetUserGroupIds returns all group IDs the user belongs to. Used for share audience resolution.

func (*Postgres) Init

func (p *Postgres) Init() error

Init opens the connection pool and applies the embedded goose migrations.

func (*Postgres) InitSharesTables

func (p *Postgres) InitSharesTables() error

func (*Postgres) InitUsersTable

func (p *Postgres) InitUsersTable() error

func (*Postgres) IsMember

func (p *Postgres) IsMember(userId, companyId string) (bool, error)

func (*Postgres) IsRevoked

func (p *Postgres) IsRevoked(jti string) (bool, error)

func (*Postgres) ListCatalogShares

func (p *Postgres) ListCatalogShares(limit int) ([]models.CatalogRow, error)

func (*Postgres) ListCompaniesForUser

func (p *Postgres) ListCompaniesForUser(username string) ([]models.Company, error)

func (*Postgres) ListGroupsByCompany

func (p *Postgres) ListGroupsByCompany(companyId string) ([]models.Group, error)

func (*Postgres) ListInboxShares

func (p *Postgres) ListInboxShares(caller string, companyIds, groupIds []string) ([]models.ElementShareSummary, error)

func (*Postgres) Pool

func (p *Postgres) Pool() *pgxpool.Pool

Pool returns the open connection pool. It is nil until Init succeeds.

func (*Postgres) RemoveGroupMember

func (p *Postgres) RemoveGroupMember(groupId, userId string) error

func (*Postgres) RemoveMembership

func (p *Postgres) RemoveMembership(userId, companyId string) error

func (*Postgres) RestoreHistory

func (p *Postgres) RestoreHistory(historyId, dagId string) error

func (*Postgres) RevokeElementShare

func (p *Postgres) RevokeElementShare(id string) error

func (*Postgres) RevokeShare

func (p *Postgres) RevokeShare(jti string) error

func (*Postgres) SetPublic

func (p *Postgres) SetPublic(id string, public bool) error

SetPublic toggles whether a DAG is publicly readable without authentication.

func (*Postgres) UpdateDAG

func (p *Postgres) UpdateDAG(id string, updates models.Dag) error

UpdateDAG merges only the non-zero fields. Every content save atomically increments embed_revision so caches can reliably detect stale renders.

func (*Postgres) UpdateMenu

func (p *Postgres) UpdateMenu(id string, updates models.Menu) error

func (*Postgres) UpdateUserPassword

func (p *Postgres) UpdateUserPassword(username, passwordHash string) error

func (*Postgres) UpsertGroupByExternalRef

func (p *Postgres) UpsertGroupByExternalRef(g models.Group) (string, error)

UpsertGroupByExternalRef creates or updates a group keyed by (companyId, externalRef). Returns the group ID. Used by LDAP login to sync AD groups.

Jump to

Keyboard shortcuts

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