Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
boblail opened this issue Dec 28, 2018 · 1 comment
Labels

Comments

@boblail
Copy link
Owner

boblail commented Dec 28, 2018

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.

@boblail boblail added the idea label Dec 28, 2018
@boblail
Copy link
Owner Author

boblail commented Jan 2, 2019

If this can be done, we would prohibit statements like this:

set :search_result_type, "Book"
set :search_result_id, Book.arel_table[:id]

And terminology like this might make sense:

Hayfork.maintain(Haystack) do
  find(Employee) do
    by(:full_name)
  end
  find(Project) do
    by(:title)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant