* 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
29 lines
654 B
Go
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
|
|
}
|