Files
nostrlib/eventstore
fiatjaf c6bd1ee446 khatru: fix bbolt halting problem by deleting outside of the loop that fetches events to be deleted.
fixes nostr:nevent1qvzqqqqx25pzq2f38nys0gq4hs5k4l4s426689psdk7d52kzjk9s0ypne2nt7927qy88wumn8ghj7mn0wvhxcmmv9uq32amnwvaz7tmjv4kxz7fwv3sk6atn9e5k7tcqyphrdv7jerr3f5mtlpcl7j7dg26ecxj9vrd5pyf0jknkqmp5qyyj28gxd3q
2025-12-19 00:23:21 -03:00
..
2025-12-18 13:26:09 -03:00
2025-05-12 10:18:06 -03:00
2025-11-23 06:57:54 -03:00
2025-11-30 22:41:31 -03:00
2025-04-15 08:49:28 -03:00
2025-04-15 08:49:28 -03:00

eventstore

A collection of reusable database connectors, wrappers and schemas that store Nostr events and expose a simple Go interface:

type Store interface {
	// Init is called at the very beginning by [Server.Start], after [Relay.Init],
	// allowing a storage to initialize its internal resources.
	Init() error

	// Close must be called after you're done using the store, to free up resources and so on.
	Close()

	// QueryEvents returns events that match the filter
	QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nostr.Event]

	// DeleteEvent deletes an event atomically by ID
	DeleteEvent(nostr.ID) error

	// SaveEvent just saves an event, no side-effects.
	SaveEvent(nostr.Event) error

	// ReplaceEvent atomically replaces a replaceable or addressable event.
	// Conceptually it is like a Query->Delete->Save, but streamlined.
	ReplaceEvent(nostr.Event) error

	// CountEvents counts all events that match a given filter
	CountEvents(nostr.Filter) (uint32, error)
}

Go Reference Run Tests

Available Implementations

  • bleve: Full-text search and indexing using the Bleve search library
  • boltdb: Embedded key-value database using BoltDB
  • lmdb: High-performance embedded database using LMDB
  • mmm: Custom memory-mapped storage with advanced indexing
  • nullstore: No-op store for testing and development
  • slicestore: Simple in-memory slice-based store

Command-line Tool

There is an eventstore command-line tool that can be used to query these databases directly.