Files
nostrlib/eventstore/bleve/save.go
fiatjaf 98959e73e7 eventstore: replace bluge with bleve.
bluge seems to be abandoned and bleve should work better, who knows.
2025-11-23 06:57:54 -03:00

24 lines
468 B
Go

package bleve
import (
"fmt"
"strconv"
"fiatjaf.com/nostr"
)
func (b *BleveBackend) SaveEvent(evt nostr.Event) error {
doc := map[string]interface{}{
contentField: evt.Content,
kindField: strconv.Itoa(int(evt.Kind)),
pubkeyField: evt.PubKey.Hex()[56:],
createdAtField: float64(evt.CreatedAt),
}
if err := b.index.Index(evt.ID.Hex(), doc); err != nil {
return fmt.Errorf("failed to index '%s' document: %w", evt.ID, err)
}
return nil
}