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

postgres

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

func Connect

func Connect(ctx context.Context, databaseURL string) (*Store, error)

func ConnectWithBlob

func ConnectWithBlob(ctx context.Context, databaseURL string, blobs blob.Store) (*Store, error)

func New

func New(db *pgxpool.Pool) *Store

func NewWithBlob

func NewWithBlob(db *pgxpool.Pool, blobs blob.Store) *Store

func (*Store) AcceptOwnershipTransfer

func (s *Store) AcceptOwnershipTransfer(ctx context.Context, id string, user auth.Principal) (repo.OwnershipTransfer, error)

func (*Store) AppendDocumentEvent

func (s *Store) AppendDocumentEvent(ctx context.Context, documentID, kind string, data json.RawMessage, actor auth.Principal) error

func (*Store) ClaimCommentNotification

func (s *Store) ClaimCommentNotification(ctx context.Context) (*repo.CommentNotification, error)

A lease outlives the sender's deadline and lets another process recover work after a crash. Successful delivery deletes the row immediately.

func (*Store) ClaimDocumentAccessNotification

func (s *Store) ClaimDocumentAccessNotification(ctx context.Context) (*repo.DocumentAccessNotification, error)

func (*Store) ClaimDocumentAccessRequestNotification

func (s *Store) ClaimDocumentAccessRequestNotification(ctx context.Context) (*repo.DocumentAccessRequestNotification, error)

func (*Store) Close

func (s *Store) Close()

func (*Store) CreateCLICredential

func (s *Store) CreateCLICredential(ctx context.Context, userID, name, tokenHash string) (string, error)

func (*Store) CreateComment

func (s *Store) CreateComment(ctx context.Context, documentID, versionID, body string, anchor repo.Anchor, author auth.Principal, mentions []repo.CommentMention) (repo.Comment, error)

func (*Store) CreateCommentReply

func (s *Store) CreateCommentReply(ctx context.Context, documentID, parentCommentID, body string, author auth.Principal, mentions []repo.CommentMention) (repo.Comment, error)

func (*Store) CreateDocument

func (s *Store) CreateDocument(ctx context.Context, owner auth.Principal, title string, html []byte) (repo.Document, repo.Version, error)

func (*Store) CreateFolder

func (s *Store) CreateFolder(ctx context.Context, owner auth.Principal, title, parent string) (repo.Folder, error)

func (*Store) CreateGrant

func (s *Store) CreateGrant(ctx context.Context, resourceType, resourceID string, principal auth.Principal, role repo.Role, grantedBy auth.Principal) (repo.Grant, error)

CreateGrant changes access without creating or updating user profiles.

func (*Store) CreateOwnershipTransfer

func (s *Store) CreateOwnershipTransfer(ctx context.Context, saID string, from auth.Principal, toEmail string) (repo.OwnershipTransfer, error)

func (*Store) CreateServiceAccount

func (s *Store) CreateServiceAccount(ctx context.Context, owner auth.Principal, name string) (repo.ServiceAccount, error)

func (*Store) CreateServiceAccountKey

func (s *Store) CreateServiceAccountKey(ctx context.Context, saID, name, tokenHash string) (string, error)

func (*Store) CreateVersion

func (s *Store) CreateVersion(ctx context.Context, documentID, baseVersionID, changeSummary string, html []byte, createdBy auth.Principal) (repo.Version, error)

func (*Store) CurrentDocumentKVRevision

func (s *Store) CurrentDocumentKVRevision(ctx context.Context, documentID string) (int64, error)

CurrentDocumentKVRevision returns the persisted high-water mark used to initialize the process-local event broker for a document.

func (*Store) DeclineOwnershipTransfer

func (s *Store) DeclineOwnershipTransfer(ctx context.Context, id string, user auth.Principal) error

func (*Store) DeleteComment

func (s *Store) DeleteComment(ctx context.Context, id string) error

func (*Store) DeleteCommentReaction

func (s *Store) DeleteCommentReaction(ctx context.Context, commentID string, p auth.Principal, emoji string) error

func (*Store) DeleteDocument

func (s *Store) DeleteDocument(ctx context.Context, id string) error

func (*Store) DeleteFolder

func (s *Store) DeleteFolder(ctx context.Context, id string, p auth.Principal) error

func (*Store) DeleteGitHubConnection

func (s *Store) DeleteGitHubConnection(ctx context.Context, userID string) error

func (*Store) DeleteGrant

func (s *Store) DeleteGrant(ctx context.Context, resourceID, grantID string, deletedBy auth.Principal) error

func (*Store) DeletePin

func (s *Store) DeletePin(ctx context.Context, p auth.Principal, rt, rid string) error

func (*Store) DirectDocumentGrantRole

func (s *Store) DirectDocumentGrantRole(ctx context.Context, documentID, userID string) (repo.Role, error)

func (*Store) EnsureUserByEmail

func (s *Store) EnsureUserByEmail(ctx context.Context, email string) (auth.Principal, error)

func (*Store) FinishCommentNotification

func (s *Store) FinishCommentNotification(ctx context.Context, n repo.CommentNotification, retryAfter time.Duration) error

func (*Store) FinishDocumentAccessNotification

func (s *Store) FinishDocumentAccessNotification(ctx context.Context, n repo.DocumentAccessNotification, retryAfter time.Duration) error

func (*Store) FinishDocumentAccessRequestNotification

func (s *Store) FinishDocumentAccessRequestNotification(ctx context.Context, n repo.DocumentAccessRequestNotification, retryAfter time.Duration) error

func (*Store) FolderAccessChain

func (s *Store) FolderAccessChain(ctx context.Context, p auth.Principal, folderID string) ([]repo.FolderAccess, error)

FolderAccessChain returns the folder's ancestor chain (root first, the folder itself last) together with the principal's effective role at each level, resolved in a single query. It returns repo.ErrNotFound when the folder does not exist; a chain entry's role is repo.RoleNone when the principal has no access at that level.

func (*Store) FolderHasGrants

func (s *Store) FolderHasGrants(ctx context.Context, folderID string) (bool, error)

func (*Store) GetComment

func (s *Store) GetComment(ctx context.Context, id string) (repo.Comment, error)

func (*Store) GetDocument

func (s *Store) GetDocument(ctx context.Context, id string) (repo.Document, error)

func (*Store) GetFolder

func (s *Store) GetFolder(ctx context.Context, id string) (repo.Folder, error)

func (*Store) GetGitHubConnection

func (s *Store) GetGitHubConnection(ctx context.Context, userID string) (repo.GitHubConnection, error)

func (*Store) GetServiceAccount

func (s *Store) GetServiceAccount(ctx context.Context, id string) (repo.ServiceAccount, error)

func (*Store) GetServiceAccountByName

func (s *Store) GetServiceAccountByName(ctx context.Context, name string) (repo.ServiceAccount, error)

func (*Store) GetVersion

func (s *Store) GetVersion(ctx context.Context, id string) (repo.Version, error)

func (*Store) GetVersionHTML

func (s *Store) GetVersionHTML(ctx context.Context, id string) ([]byte, error)

func (*Store) GoogleGroupMembershipSnapshot

func (s *Store) GoogleGroupMembershipSnapshot(ctx context.Context, userID string) (repo.GoogleGroupMembershipSnapshot, error)

func (*Store) HideFeaturedItem

func (s *Store) HideFeaturedItem(ctx context.Context, p auth.Principal, rid string) error

func (*Store) IndexDocuments added in v0.3.0

func (s *Store) IndexDocuments(ctx context.Context) (indexed int, err error)

IndexDocuments gives a search vector to documents that were created before documents had one. IndexDocuments returns the number of documents that it indexed.

func (*Store) IndexVersions

func (s *Store) IndexVersions(ctx context.Context) (indexed int, err error)

IndexVersions gives search text to current versions that were created before content search. Each batch locks its versions, so all servers can run it at the same time. A version that cannot be read is skipped until the next run. IndexVersions returns the number of versions that it indexed.

func (*Store) ListCLICredentials

func (s *Store) ListCLICredentials(ctx context.Context, userID string) ([]repo.CLICredential, error)

func (*Store) ListComments

func (s *Store) ListComments(ctx context.Context, documentID, status, versionID string) ([]repo.Comment, error)

func (*Store) ListDocumentKV

func (s *Store) ListDocumentKV(ctx context.Context, documentID string) (repo.DocumentKVSnapshot, error)

func (*Store) ListDocumentKVEvents

func (s *Store) ListDocumentKVEvents(ctx context.Context, documentID string, afterRevision int64, limit int32) ([]repo.DocumentKVEvent, error)

func (*Store) ListDocumentLabels

func (s *Store) ListDocumentLabels(ctx context.Context, documentID string) ([]string, error)

func (*Store) ListDocumentPresence

func (s *Store) ListDocumentPresence(ctx context.Context, documentID string, maxAge time.Duration) ([]repo.DocumentKVEvent, error)

func (*Store) ListDocuments

func (s *Store) ListDocuments(ctx context.Context, p auth.Principal) ([]repo.Document, error)

func (*Store) ListDocumentsByLabel

func (s *Store) ListDocumentsByLabel(ctx context.Context, p auth.Principal, label string) ([]repo.Document, error)

func (*Store) ListEffectiveAccess

func (s *Store) ListEffectiveAccess(ctx context.Context, rt, rid string) ([]repo.EffectiveAccessItem, error)

func (*Store) ListFolder

func (s *Store) ListFolder(ctx context.Context, p auth.Principal, folderID, path string) ([]repo.FolderEntry, bool, *repo.Folder, error)

func (*Store) ListFolderDocuments

func (s *Store) ListFolderDocuments(ctx context.Context, _ auth.Principal, folderID string) ([]repo.Document, error)

func (*Store) ListGitHubAuthorAccess

func (s *Store) ListGitHubAuthorAccess(ctx context.Context, documentID, owner, repoName string, freshAfter time.Time) ([]repo.GitHubAuthorAccess, error)

func (*Store) ListGrants

func (s *Store) ListGrants(ctx context.Context, resourceID string) ([]repo.Grant, error)

func (*Store) ListHiddenFeaturedItems

func (s *Store) ListHiddenFeaturedItems(ctx context.Context, p auth.Principal) ([]string, error)

func (*Store) ListOwnershipTransfers

func (s *Store) ListOwnershipTransfers(ctx context.Context, user auth.Principal) ([]repo.OwnershipTransfer, error)

func (*Store) ListPins

func (s *Store) ListPins(ctx context.Context, p auth.Principal) ([]repo.Pin, error)

func (*Store) ListServiceAccountKeys

func (s *Store) ListServiceAccountKeys(ctx context.Context, saID string) ([]repo.ServiceAccountKey, error)

func (*Store) ListServiceAccounts

func (s *Store) ListServiceAccounts(ctx context.Context, owner auth.Principal) ([]repo.ServiceAccount, error)

func (*Store) ListVersions

func (s *Store) ListVersions(ctx context.Context, documentID string) ([]repo.Version, error)

func (*Store) MoveDocumentToFolder

func (s *Store) MoveDocumentToFolder(ctx context.Context, _ auth.Principal, folderID, docID string) (bool, error)

func (*Store) MoveDocumentToRoot

func (s *Store) MoveDocumentToRoot(ctx context.Context, folderID, docID string) error

func (*Store) NotificationPreferences

func (s *Store) NotificationPreferences(ctx context.Context, p auth.Principal, documentID string) (repo.NotificationPreferences, error)

func (*Store) PatchDocumentKV

func (s *Store) PatchDocumentKV(ctx context.Context, documentID string, set map[string]json.RawMessage, deleteKeys []string, actor auth.Principal) (repo.DocumentKVPatchResult, error)

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

func (*Store) Pool

func (s *Store) Pool() *pgxpool.Pool

func (*Store) PrincipalExists

func (s *Store) PrincipalExists(ctx context.Context, p auth.Principal) (bool, error)

func (*Store) PutCommentReaction

func (s *Store) PutCommentReaction(ctx context.Context, commentID string, p auth.Principal, emoji string) error

func (*Store) PutPin

func (s *Store) PutPin(ctx context.Context, p auth.Principal, rt, rid string) error

func (*Store) RecordDocumentOpened

func (s *Store) RecordDocumentOpened(ctx context.Context, documentID string, p auth.Principal) error

func (*Store) RecordFolderOpened

func (s *Store) RecordFolderOpened(ctx context.Context, folderID string, p auth.Principal) error

func (*Store) RecordGitHubRepoAccess

func (s *Store) RecordGitHubRepoAccess(ctx context.Context, userID, owner, repoName string, canRead bool) error

func (*Store) RecordGoogleGroupMembershipFailure

func (s *Store) RecordGoogleGroupMembershipFailure(ctx context.Context, userID, errorCode string, attemptedAt time.Time) error

func (*Store) ReplaceDocumentLabels

func (s *Store) ReplaceDocumentLabels(ctx context.Context, documentID string, labels []string, actor auth.Principal) ([]string, error)

func (*Store) ReplaceGoogleGroupMemberships

func (s *Store) ReplaceGoogleGroupMemberships(ctx context.Context, userID string, groups []repo.GoogleGroup, syncedAt time.Time) error

func (*Store) RequestDocumentAccess

func (s *Store) RequestDocumentAccess(ctx context.Context, requester auth.Principal, documentID string) error

RequestDocumentAccess deliberately returns no existence or owner detail. A repeated request within 24 hours is accepted but does not notify again.

func (*Store) ReserveNotificationDelivery

func (s *Store) ReserveNotificationDelivery(ctx context.Context, userID string) (bool, error)

A database gate applies across replicas, separately from Slack's rate limits.

func (*Store) ResolveBearerToken

func (s *Store) ResolveBearerToken(ctx context.Context, tokenHash string) (auth.Principal, error)

func (*Store) ResolveUser

func (s *Store) ResolveUser(ctx context.Context, id string) (auth.Principal, error)

func (*Store) RevokeCLICredential

func (s *Store) RevokeCLICredential(ctx context.Context, userID, credentialID string) error

func (*Store) RevokeServiceAccountKey

func (s *Store) RevokeServiceAccountKey(ctx context.Context, saID, keyID string) error

func (*Store) RoleForDocument

func (s *Store) RoleForDocument(ctx context.Context, p auth.Principal, documentID string) (repo.Role, error)

func (*Store) RoleForFolder

func (s *Store) RoleForFolder(ctx context.Context, p auth.Principal, folderID string) (repo.Role, error)

func (*Store) SearchContacts added in v0.2.1

func (s *Store) SearchContacts(ctx context.Context, caller auth.Principal, query string) ([]auth.Principal, error)

func (*Store) SearchDocuments

func (s *Store) SearchDocuments(ctx context.Context, p auth.Principal, search repo.DocumentSearch, includeOrgWide bool, limit int32) ([]repo.Document, error)

func (*Store) SearchFoldersByTitle

func (s *Store) SearchFoldersByTitle(ctx context.Context, p auth.Principal, query string, includeOrgWide bool, limit int32) ([]repo.Folder, error)

func (*Store) SearchUsersByEmail

func (s *Store) SearchUsersByEmail(ctx context.Context, query string) ([]auth.Principal, error)

func (*Store) SetNotificationPreferences

func (s *Store) SetNotificationPreferences(ctx context.Context, p auth.Principal, documentID string, enabled bool) (repo.NotificationPreferences, error)

func (*Store) SetNotificationsEnabled

func (s *Store) SetNotificationsEnabled(enabled bool)

func (*Store) UpdateComment

func (s *Store) UpdateComment(ctx context.Context, id string, update repo.CommentUpdate) (repo.Comment, error)

func (*Store) UpdateDocument

func (s *Store) UpdateDocument(ctx context.Context, id, title string) (repo.Document, error)

func (*Store) UpdateFolder

func (s *Store) UpdateFolder(ctx context.Context, id, title string, parent *string) (repo.Folder, error)

func (*Store) UpdateGrant

func (s *Store) UpdateGrant(ctx context.Context, resourceID, grantID string, role repo.Role, updatedBy auth.Principal) (repo.Grant, error)

func (*Store) UpdateServiceAccount

func (s *Store) UpdateServiceAccount(ctx context.Context, id, name string, disabled *bool) (repo.ServiceAccount, error)

func (*Store) UpsertGitHubConnection

func (s *Store) UpsertGitHubConnection(ctx context.Context, c repo.GitHubConnection) error

func (*Store) UpsertGoogleGroup

func (s *Store) UpsertGoogleGroup(ctx context.Context, group repo.GoogleGroup) error

func (*Store) UpsertGoogleUser

func (s *Store) UpsertGoogleUser(ctx context.Context, id, email, name, googleSub, pictureURL string) (auth.Principal, error)

func (*Store) UserByEmail

func (s *Store) UserByEmail(ctx context.Context, email string) (auth.Principal, error)

Jump to

Keyboard shortcuts

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