jonbirke0927
Extract query attributes from an ecto query
Hello all!
I’m wondering if anyone is aware of a way to obtain the various attributes from a variable of type Ecto.Query, using only the query itself. For example, if I have the variable query = #Ecto.Query<from c0 in App.Context.Sub, order_by: [asc: c0.column1]>, I am hoping to be able to do something like Ecto.Query.get_order_by(query) => {asc: :column1}.
For additional context, we currently have function that return paginated resources. We are thinking that we probably want to extract out pagination into its own module, and in order to do this cleanly, we would need to be able to determine how a query is sorted from only the query itself. This way we are able to properly assign cursor fields for cursor-based pagination.
Thanks in advance!
Most Liked
al2o3cr
LostKobrakai
Ecto querys have only opaque field values. They may change at any given time. Therefore inspecting ecto queries is not possible in a safe manner.
Popular in Questions
Other popular topics
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
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









