dendrite.nvim/persistence/repositories/index_repository.go
Kristian c1feac0812
feat(rebuild_guard): only build index on init if empty index (#30)
* feat(persistence): added build-flag and repo funcs

* feat(init_handler): note count check to avoid unnecessary rebuilds

* ref(build_flag): remove build flag is redundant

* build
2026-04-23 20:38:37 +02:00

29 lines
654 B
Go

package repositories
import (
"context"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence"
)
type IIndexRepository interface {
WipeIndex(ctx context.Context, dbContext persistence.IDbContext) error
}
type indexRepository struct {
readDBContext persistence.ReadContext
}
func NewIndexRepository(rdb persistence.ReadContext) IIndexRepository {
return &indexRepository{readDBContext: rdb}
}
func (r *indexRepository) WipeIndex(ctx context.Context, dbContext persistence.IDbContext) error {
cmd := `DELETE FROM note;
DELETE FROM tag;
DELETE FROM note_tag;
DELETE FROM link;`
_, err := dbContext.ExecContext(ctx, cmd)
return err
}