The README points out how a second foreach block must be defined when working with associations; and that this is not adequate:
Hayfork.maintain(Haystack) do
foreach(Book) do
insert(:title)
insert(author: :name)
end
end
Instead, Hayfork could automatically define triggers based on insert(author: :name) to watch authors and repopulate the haystack.
While implementing this technique, we should decide between two paths for how Hayfork handles has_many associations. In the event that one of an article's comments is updated, we could either:
- Wipe out all the
comments entries for that post and regenerate all of them
- Surgically replace just the entries for the updated comment
The latter is how the README's example currently works; but combining the former strategy with #1 would also remove the need for a ref_id column.
The README points out how a second
foreachblock must be defined when working with associations; and that this is not adequate:Instead, Hayfork could automatically define triggers based on
insert(author: :name)to watch authors and repopulate the haystack.While implementing this technique, we should decide between two paths for how Hayfork handles
has_manyassociations. In the event that one of an article's comments is updated, we could either:commentsentries for that post and regenerate all of themThe latter is how the README's example currently works; but combining the former strategy with #1 would also remove the need for a
ref_idcolumn.