shahryarjb
How to do multi selects in Ecto
hello,
I have a challenge which I should do it. I need multi values in my db with Ecto, but I need to pass it like one request
please see my image :
for example when my user calls my router link , I should pass this :
- count all records of category one
- load and count all records of the category one which its version_id = 1 along with its fields
- lists of all version along with its title and id
Do I send 3 Repo.all to my db with Ecto or something else?
I want to create like this : EasyBlog - Changelog for 6.0.18
My client only sends Category Id and I should pass like this Json example :
Category_id == 1
[
category_info: [
count_all_records: 100,
count_all_records_by_version_one: 10
load_list_of_version: [
{
name: "1.5",
id: 1
},
{
name: "1.7",
id: 2
},
{
name: "1.6",
id: 3
},
{
name: "3",
id: 4
}
]
]
category_records: [
{
name: "bug fix 1",
id: 1
version_id: 1
},
{
name: "bug fix 2",
id: 3
version_id: 3
},
{
name: "bug fix 3",
id: 10
version_id: 3
},
]
]
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Hello !
We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security












First 6 of 6 Posts
peerreynders
This part doesn’t make any sense.
versionholds “zero or more” versions for any onecategory. Soversion.id = 1would belong to exactly onecategory.min(version.id)(or more likelymax(version.id)for the specified singlecategory.shahryarjb
unfortunately I didn’t understand what you said, I’m sorry.
version.titleis a string field andversion_idrelationed with record table, In fact, this is a filter, if it doesn’t answer me, so what do I do? I’m confused.I just need to get table records which relation with
Versiontable in the Category concerned( category id = 2) . how can I do? I’m new to this field , I sorry and thank you for giving me your time.shahryarjb
Ok , hmm, now I know it , but what is your suggestion? but I think it isn’t only problem , my main problem is how to write query for this , even if this logic is wrong.I’m confused.

So, I am thinking my way may be right, because at first, I print all Version of category which relation, and my user selects each one and sends it.
My
version_idis aUUID, for this purpose, I want to print all versions of category with other query. if my client didn’t send anyversion_id, I would selectmax(version_title)of category which relation it.Is my idea correct?
peerreynders
This is the organization that makes sense to me:
shahryarjb
At first, I am very grateful to you.
it seems that I need to use Query 2, it works with normal ID like integer, but I am using UUID, or I have to use normal ID or I should find the way which I will be able to fix it.
Your Post and codes are the best practice for me, Thank you.
Edited
I edited like this :
Versionsfunction is true, butcountsfunction which has a problem shows me this :Edit 2
I edited again :
The previous problem was solved but …
peerreynders
It seems that PostgreSQL can’t compare UUIDs directly but only use them in JOINS. Try this version: