barnabasj
AEAsh Elixir
•Created by Stephan on 11/11/2023 in #support
How to define custom sort?
also you need to put
prepare
before build
e.g. prepare build(:sort, [intereset_at: :asc])
4 replies
AEAsh Elixir
•Created by Stephan on 11/11/2023 in #support
How to define custom sort?
in this case you would probably do a custom preparation like this
4 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
so you can use it with ecto just like before
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
The resource also defines an ecto schema
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
My bad, I probably made it more complicated than it is, I also didn't think of the
Api.count()
function34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
but you would probably need to call the aggregate through a calculation because aggregates themself do not support arguments
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
but to me it feels a bit wrong, I would probably create some kind of
parking_space
resource and that would have_many
cars
and add the aggregate on the parking_space34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
the easiest way would probably be to just add a calulation and use the fragment. I would probably model it a bit differently
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
can you give me a real world example of what you are trying to do?
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
What might be important is that you set up the aggregates on the "parent" resource. You add the relationships to the resource and then you can run aggregates on them.
34 replies
AEAsh Elixir
•Created by tellesleandro on 9/27/2023 in #support
Ash.Query getting started docs
For things like that you would use Aggregates https://hexdocs.pm/ash/aggregates.html
34 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
If you don't have a strong reason I would just keep the current behaviour if everything else is working the way you want.
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
postgres is pretty good with json these days. and you get more functionality from a jsonb column than just text, you could potentially index the fields inside the struct if necesary and it's easier to filter
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
Do you need it to be a string in the db for some kind of compatability reasons or what is your reasoning for not saving it as a :map (jsonb) column?
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
Or you could define your own custom type https://hexdocs.pm/ash/Ash.Type.html#module-defining-custom-types that knows how to take in the values and transforms them into a string
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
or you could just save it as a map and add a calculation that turns it into a string during a read
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
What you could do is use just string as the type in your resource, and then take in the schedule datastructure as an argument and cast it into a string before writing it onto the attribute.
Something like
13 replies
AEAsh Elixir
•Created by miguels on 9/27/2023 in #support
Persist embedded resources as :text instead of :map
Or rather, what are you trying to achieve? There are probably ways to make this work, but I think I'm not understanding the whole problem here.
13 replies