Documentation
¶
Index ¶
- Variables
- type Postgres
- func (p *Postgres) AddGroupMember(gm models.GroupMember) error
- func (p *Postgres) AddMembership(m models.Membership) error
- func (p *Postgres) AppendHistory(dagId, snapshotJSON, savedBy string) error
- func (p *Postgres) AppendImportedBy(id, username string) error
- func (p Postgres) Configured() bool
- func (p *Postgres) CreateCompany(c models.Company) (string, error)
- func (p *Postgres) CreateDAG(dag models.Dag) (string, error)
- func (p *Postgres) CreateDAGs(dags []models.Dag) (ids []string, err error)
- func (p *Postgres) CreateEdge(edge models.Edge) (string, error)
- func (p *Postgres) CreateEdges(edges []models.Edge) (ids []string, err error)
- func (p *Postgres) CreateElementShare(s models.ElementShare) (string, error)
- func (p *Postgres) CreateGroup(g models.Group) (string, error)
- func (p *Postgres) CreateMenu(menu models.Menu) (string, error)
- func (p *Postgres) CreateMenus(menus []models.Menu) (ids []string, err error)
- func (p *Postgres) CreateNode(node models.Node) (string, error)
- func (p *Postgres) CreateNodes(nodes []models.Node) (ids []string, err error)
- func (p *Postgres) CreateShare(s models.Share) error
- func (p *Postgres) CreateUser(u models.User) error
- func (p *Postgres) DeleteCompany(id string) error
- func (p *Postgres) DeleteDAG(id string) error
- func (p *Postgres) DeleteEdge(id string) error
- func (p *Postgres) DeleteGroup(id string) error
- func (p *Postgres) DeleteMenu(id string) error
- func (p *Postgres) DeleteNode(id string) error
- func (p Postgres) EffectiveDSN() string
- func (p *Postgres) FindRelatedDAG(dag models.Dag) (relatedDAG models.Dag, foundDAG bool, err error)
- func (p *Postgres) FindRelatedEdge(edge models.Edge) (relatedEdge models.Edge, foundEdge bool, err error)
- func (p *Postgres) FindRelatedMenu(menu models.Menu) (relatedMenu models.Menu, foundMenu bool, err error)
- func (p *Postgres) FindRelatedNode(node models.Node) (relatedNode models.Node, foundNode bool, err error)
- func (p *Postgres) GetCompany(id string) (models.Company, error)
- func (p *Postgres) GetCompanyMembers(companyId string) ([]string, error)
- func (p *Postgres) GetDAG(id string) (dag models.Dag, err error)
- func (p *Postgres) GetDAGPublic(id string) (dag models.Dag, err error)
- func (p *Postgres) GetDAGsSummary(queryArgs map[string][]string) (dagsSummary []map[string]interface{}, err error)
- func (p *Postgres) GetEdge(id string) (edge models.Edge, err error)
- func (p *Postgres) GetEdgesSummary(queryArgs map[string][]string) (edgesSummary []map[string]interface{}, err error)
- func (p *Postgres) GetElementShare(id string) (models.ElementShare, error)
- func (p *Postgres) GetElementShareByJti(jti string) (models.ElementShare, error)
- func (p *Postgres) GetGroup(id string) (models.Group, error)
- func (p *Postgres) GetGroupMembers(groupId string) ([]string, error)
- func (p *Postgres) GetHistory(dagId string) ([]models.DagHistory, error)
- func (p *Postgres) GetMenu(id string) (menu models.Menu, err error)
- func (p *Postgres) GetMenusOptions(queryArgs map[string][]string) (menusOptions map[string]models.Menu, err error)
- func (p *Postgres) GetMenusSummary(queryArgs map[string][]string) (menusSummary []map[string]interface{}, err error)
- func (p *Postgres) GetNode(id string) (node models.Node, err error)
- func (p *Postgres) GetNodesSummary(queryArgs map[string][]string) (nodesSummary []map[string]interface{}, err error)
- func (p *Postgres) GetShareByJti(jti string) (models.Share, error)
- func (p *Postgres) GetUser(username string) (models.User, error)
- func (p *Postgres) GetUserCompanyIds(username string) ([]string, error)
- func (p *Postgres) GetUserGroupIds(username string) ([]string, error)
- func (p *Postgres) Init() error
- func (p *Postgres) InitSharesTables() error
- func (p *Postgres) InitUsersTable() error
- func (p *Postgres) IsMember(userId, companyId string) (bool, error)
- func (p *Postgres) IsRevoked(jti string) (bool, error)
- func (p *Postgres) ListCatalogShares(limit int) ([]models.CatalogRow, error)
- func (p *Postgres) ListCompaniesForUser(username string) ([]models.Company, error)
- func (p *Postgres) ListGroupsByCompany(companyId string) ([]models.Group, error)
- func (p *Postgres) ListInboxShares(caller string, companyIds, groupIds []string) ([]models.ElementShareSummary, error)
- func (p *Postgres) Pool() *pgxpool.Pool
- func (p *Postgres) RemoveGroupMember(groupId, userId string) error
- func (p *Postgres) RemoveMembership(userId, companyId string) error
- func (p *Postgres) RestoreHistory(historyId, dagId string) error
- func (p *Postgres) RevokeElementShare(id string) error
- func (p *Postgres) RevokeShare(jti string) error
- func (p *Postgres) SetPublic(id string, public bool) error
- func (p *Postgres) UpdateDAG(id string, updates models.Dag) error
- func (p *Postgres) UpdateMenu(id string, updates models.Menu) error
- func (p *Postgres) UpdateUserPassword(username, passwordHash string) error
- func (p *Postgres) UpsertGroupByExternalRef(g models.Group) (string, error)
Constants ¶
This section is empty.
Variables ¶
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 (*Postgres) AppendImportedBy ¶
func (Postgres) Configured ¶
Configured reports whether any connection setting was provided.
func (*Postgres) CreateDAGs ¶
func (*Postgres) CreateEdges ¶
func (*Postgres) CreateElementShare ¶
func (p *Postgres) CreateElementShare(s models.ElementShare) (string, error)
func (*Postgres) CreateMenus ¶
func (*Postgres) CreateNodes ¶
func (*Postgres) DeleteCompany ¶
func (*Postgres) DeleteEdge ¶
func (*Postgres) DeleteGroup ¶
func (*Postgres) DeleteMenu ¶
func (*Postgres) DeleteNode ¶
func (Postgres) EffectiveDSN ¶
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 (*Postgres) FindRelatedEdge ¶
func (*Postgres) FindRelatedMenu ¶
func (*Postgres) FindRelatedNode ¶
func (*Postgres) GetCompanyMembers ¶
func (*Postgres) GetDAGPublic ¶
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 (*Postgres) GetEdgesSummary ¶
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) GetGroupMembers ¶
func (*Postgres) GetHistory ¶
func (p *Postgres) GetHistory(dagId string) ([]models.DagHistory, error)
func (*Postgres) GetMenusOptions ¶
func (*Postgres) GetMenusSummary ¶
func (*Postgres) GetNodesSummary ¶
func (*Postgres) GetUserCompanyIds ¶
GetUserCompanyIds returns all company IDs the user belongs to. Used for share audience resolution.
func (*Postgres) GetUserGroupIds ¶
GetUserGroupIds returns all group IDs the user belongs to. Used for share audience resolution.
func (*Postgres) InitSharesTables ¶
func (*Postgres) InitUsersTable ¶
func (*Postgres) ListCatalogShares ¶
func (p *Postgres) ListCatalogShares(limit int) ([]models.CatalogRow, error)
func (*Postgres) ListCompaniesForUser ¶
func (*Postgres) ListGroupsByCompany ¶
func (*Postgres) ListInboxShares ¶
func (*Postgres) RemoveGroupMember ¶
func (*Postgres) RemoveMembership ¶
func (*Postgres) RestoreHistory ¶
func (*Postgres) RevokeElementShare ¶
func (*Postgres) RevokeShare ¶
func (*Postgres) SetPublic ¶
SetPublic toggles whether a DAG is publicly readable without authentication.
func (*Postgres) UpdateDAG ¶
UpdateDAG merges only the non-zero fields. Every content save atomically increments embed_revision so caches can reliably detect stale renders.