feat(db): add wiki-link extraction, resolution, and backlinks
CI / test (pull_request) Successful in 2m27s
CI / test (pull_request) Successful in 2m27s
[[wiki-links]] in entry bodies are extracted at save time, resolved to entity IDs (title match first, body substring fallback), and stored in entity_links junction table. Backlinks surface in TUI detail view showing entries that link to the current entry. Schema migration v5 adds entity_links with CASCADE/SET NULL semantics. Links sync on Create, Update, and Absorb.
This commit is contained in:
@@ -152,6 +152,10 @@ func (s *Store) Create(ctx context.Context, e *Entity) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := syncLinks(ctx, tx, s, e.ID, e.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
@@ -383,6 +387,12 @@ func (s *Store) Update(ctx context.Context, id string, u *EntityUpdate) error {
|
||||
}
|
||||
}
|
||||
|
||||
if u.Body != nil {
|
||||
if err := syncLinks(ctx, tx, s, existing.ID, *u.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
@@ -495,6 +505,10 @@ func (s *Store) Absorb(ctx context.Context, targetID, sourceID string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := syncLinks(ctx, tx, s, targetID, merged); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if source.CardType != nil {
|
||||
if _, err := tx.ExecContext(ctx, `UPDATE entities SET card_type = NULL, card_data = NULL,
|
||||
use_count = 0, last_used_at = NULL, modified_at = ? WHERE id = ?`,
|
||||
|
||||
Reference in New Issue
Block a user