-
Notifications
You must be signed in to change notification settings - Fork 78
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
Non-standard source for a relationship #136
Comments
In case anyone's curious, a potential solution in the schema file:
Then adding NOTE: edited to remove incorrect |
This will work temporarily. I think a solution for this might be to allow
view functions to override relationships as well to pre-process them.
But I'm open to suggestions for this api as you're use case isn't unique
and we'll likely see it come up again.
…On Wed, Oct 3, 2018 at 2:18 PM, Kevin C. Baird ***@***.***> wrote:
In case anyone's curious, a potential solution:
field :tags, {:array, :map}, virtual: true
def inject_tags_from_tag_ids(product) do
tag_ids = product.tag_ids || []
tags = for id <- tag_ids, do: %{id: id}
%{product | tags: tags}
end
Then adding tags: {TagView, :include} to relationships in the View seems
to work OK.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#136 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGKFsEeiRKtygqiJUaRJqoXUliN8WDxks5uhQ2EgaJpZM4XE_aj>
.
|
Just spitballing on things that would've seemed easier to me. here's one idea:
The idea being that The particulars above could be modified to allow specifying |
You could also lock it down more with
That's less flexible, intended only for an input that is known to be a list of IDs (as is true for us). I'm not sure what else you might be getting in for a relationship, anyway. |
FYI, this is no longer a priority for our specific project. |
Ha! I was just contemplating this issue. Many thanks for the heads up. I'll close this issue then. |
Hi. Let's say I have a
Product
, with atag_ids
field of type{:array, :string}
.I'd like to construct a normal-appearing
tags
relationship in myProductView
, such that thetags
derive not from a regularhas_many
relationship, but rather anyTag
whose uuid primary_key is in thatproduct.tag_ids
array.Is there any reasonable way to do this?
The text was updated successfully, but these errors were encountered: