postgresql

package
v0.17.15 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Unlicense Imports: 15 Imported by: 16 modules, 14 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

This section is empty.

Variables

View Source
var (
	TooManyIDs       = errors.New("too many ids")
	TooManyAuthors   = errors.New("too many authors")
	TooManyKinds     = errors.New("too many kinds")
	TooManyTagValues = errors.New("too many tag values")
	EmptyTagSet      = errors.New("empty tag set")
)

Functions

This section is empty.

Types

type PostgresBackend

type PostgresBackend struct {
	sync.Mutex
	*sqlx.DB
	DatabaseURL             string
	QueryLimit              int
	QueryIDsLimit           int
	QueryAuthorsLimit       int
	QueryKindsLimit         int
	QueryTagsLimit          int
	KeepRecentEvents        bool
	FullTextSearchConfig    string // text search configuration for to_tsvector/to_tsquery, defaults to "simple"
	FullTextSearchMaxLength int    // maximum content length for full-text search, 0 means no limit
	FullTextSearchColumn    string // column to search in, defaults to "content"
	SubstringSearch         bool   // match NIP-50 search as an ILIKE '%q%' substring instead of tsvector full-text; see queryEventsSql
	NotifyChannel           string // LISTEN/NOTIFY channel used by Notify and Notifications, defaults to "nostr_events"
}

func (*PostgresBackend) AfterSave

func (b *PostgresBackend) AfterSave(evt *nostr.Event)

func (*PostgresBackend) BeforeSave

func (b *PostgresBackend) BeforeSave(ctx context.Context, evt *nostr.Event)

func (*PostgresBackend) Close

func (b *PostgresBackend) Close()

func (*PostgresBackend) CountEvents

func (b *PostgresBackend) CountEvents(ctx context.Context, filter nostr.Filter) (int64, error)

func (*PostgresBackend) CountEventsFilters added in v0.17.13

func (b *PostgresBackend) CountEventsFilters(ctx context.Context, filters nostr.Filters) (int64, error)

CountEventsFilters counts the events matching any of the filters, counting an event that matches more than one of them only once. NIP-45 OR's the filters together into a single count, so summing a per-filter count would report overlapping filters more than once. The union is evaluated by PostgreSQL: pulling the ids back to deduplicate them here would cost one id per stored event.

func (*PostgresBackend) DeleteEvent

func (b *PostgresBackend) DeleteEvent(ctx context.Context, evt *nostr.Event) error

func (*PostgresBackend) Init

func (b *PostgresBackend) Init() error

func (*PostgresBackend) Notifications added in v0.17.14

func (b *PostgresBackend) Notifications(ctx context.Context) (<-chan *nostr.Event, error)

Notifications listens on the NotifyChannel and delivers every event sent with Notify by any process connected to the same database. It needs DatabaseURL, since LISTEN takes over a dedicated connection.

func (*PostgresBackend) Notify added in v0.17.14

func (b *PostgresBackend) Notify(ctx context.Context, evt *nostr.Event) error

Notify sends evt on the NotifyChannel with NOTIFY, so that every process listening through Notifications receives it.

func (*PostgresBackend) QueryEvents

func (b *PostgresBackend) QueryEvents(ctx context.Context, filter nostr.Filter) (ch chan *nostr.Event, err error)

func (*PostgresBackend) ReplaceEvent added in v0.15.0

func (b *PostgresBackend) ReplaceEvent(ctx context.Context, evt *nostr.Event) error

func (*PostgresBackend) SaveEvent

func (b *PostgresBackend) SaveEvent(ctx context.Context, evt *nostr.Event) error

Jump to

Keyboard shortcuts

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