Skip to content

pippellia-btc/nastro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nastro

A collection of plug&play, yet highly configurable databases for Nostr.

Installation

go get github.com/pippellia-btc/nastro

Simple Abstraction

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)
}

Deep Customization

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.

Requirements for Databases

These are the new requirements for new databases to be added to nastro:

  1. fullfil the Store interface.
  2. expose the underlying database client (if any).
  3. allow customization of EventPolicy, FilterPolicy and other parameters with functional options.

About

A collection of plug&play and configurable databases for nostr

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages