Skip to content

Allow Hayfork to work with associations without explicitly creating the mirror triggers #2

@boblail

Description

@boblail

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:

  1. Wipe out all the comments entries for that post and regenerate all of them
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions