maz
Using Flop I want to return a list of tuples containing a Membership along with associated User.email
membership.ex:
@derive {
Flop.Schema,
filterable: [:member_email],
sortable: [:member_email],
join_fields: [member_email: [binding: :joined_user, field: :email]]
}
@role_options ~w(admin member)a
schema "orgs_memberships" do
field :role, Ecto.Enum, values: @role_options
field :is_inactive, :boolean, default: false
...
belongs_to :user, User
belongs_to :org, Org
def all_by_org_joined(%Org{} = org) do
joined = from(m in __MODULE__,
join: u in assoc(m, :user),
as: :joined_user,
join: o in assoc(m, :org),
on: o.id == ^org.id
)
dbg(joined)
result = joined
|> Markably.Repo.all()
dbg(result)
result prints as but seems to be missing member_email:
result #=> [
%Markably.Orgs.Membership{
__meta__: #Ecto.Schema.Metadata<:loaded, "orgs_memberships">,
id: "1eda8b14-bf24-6736-85c7-a1d5647b6bd8",
role: :admin,
is_inactive: false,
user_id: "1eda8b14-be9c-6822-8ab9-61e2ff5b420b",
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
org_id: "1eda8b14-bf22-6d6e-b325-ea3ac7994ddf",
org: #Ecto.Association.NotLoaded<association :org is not loaded>,
inserted_at: ~N[2023-02-09 19:38:15],
updated_at: ~N[2023-02-09 19:38:15]
},
%Markably.Orgs.Membership{
...
Am I doing this right?
flop 0.19.0
ecto 3.9.4
elixir 1.14.2
regards, Michael
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
woylie
You’re missing a
select. Flop only addswhereandorder byclauses, it won’t add aselectfor you.maz
Thanks for the response, it was helpful but there is one caveat: if I select like this I will be returning as a map, the Petal Data Table(Install) needs a struct(and also obviates the need for Flop, of course):
How do I select into a Membership struct that has the
member_emailalong with it?jswanner
You’re currently explicitly selecting a map, see Ecto.Query.API — Ecto v3.14.0 for some ways to select a struct.
maz
Thanks, that helped.