A collection of plug&play, yet highly configurable databases for Nostr.
go get github.com/pippellia-btc/nastro
All databases fullfil the Store
interface, which exposes easy to use methods for dealing with everything Nostr.
type Store interface {
Save(ctx context.Context, event *nostr.Event) error
Delete(ctx context.Context, id string) error
Replace(ctx context.Context, event *nostr.Event) (bool, error)
Query(ctx context.Context, filters ...nostr.Filter) ([]nostr.Event, error)
Count(ctx context.Context, filters ...nostr.Filter) (int64, error)
}
nastro
is designed to be minimal by default, but easily extended to fit your needs.
You can fine-tune both structure and behavior through functional options:
store, err := sqlite.New("relay.sqlite",
sqlite.WithAdditionalSchema(mySchema), // custom tables or indexes
sqlite.WithQueryBuilder(myBuilder), // override default SQL generation
sqlite.WithFilterPolicy(myPolicy), // sanitize or reject filters
)
This setup provides clean separation between core logic and custom rules, so you can adapt behavior without forking or modifying internals.
These are the new requirements for new databases to be added to nastro
:
- fullfil the
Store
interface. - expose the underlying database client (if any).
- allow customization of
EventPolicy
,FilterPolicy
and other parameters with functional options.