Where do I find documentation on `contains()` , for use within an Ash.Query.filter()?
I checked:
1. Ash.Filter: https://ash-hq.org/docs/module/ash/latest/ash-filter
2. Ash.Query: https://ash-hq.org/docs/module/ash/latest/ash-query
2. Ash.Query.filter() (which was not in alphabetical order in the
Ash.Query
functions list on the right side): https://ash-hq.org/docs/module/ash/latest/ash-query#macro-filter-2
Where can the documentation for contains()
be found?10 Replies
And I guess the bigger question is: Can Ash do SQL queries anywhere near as well as Ecto can? If I have a really complex SQL query, will I be able to do it in Ash? Ecto as
fragment()
and ilike()
, and others. I think I'll need that functionality in the future.
And if it can't do those things, what are my options?I should link there from some of those places that you searched 🙂
There are also data layer specific expressions which I'm realizing now I cannot find the documentation for unfortunately. I'll add a guide right now
To answer your specific question, Ash has
fragment/1
and so at the end of the day you can basically do anything you need.
even if you've got to put a big ugly sql query into a calculation
There are solutions if that problem gets really bad (defining views/functions in postgres), and although it can be a bit of a paradigm shift, combinations of aggregates/calculations (aggregates allow referring to calculations of related resources even) and some of the new expressions we've added like exists/2
can take you a very long way.
And then in the worst case scenarios you have:
Oh nice!
I think the most important thing to know here is that we're building a data-layer agnosting querying layer overtop of multiple data layers. All of those expressions listed in the expressions guide will work against any data layer that implements them, and that will be all core supported data layers like
Ets
Mnesia
Csv
and AshPostgres
but we understand that that is not always enough, hence deeper escape hatches & fragment/*
existingSure, I get that.
👍 the main consequence is that sometimes you have to find "resource-y" ways to state your query (and sometimes of course can't always do that). I.e "count of users grouped by org"
would really be:
on the organization resource
here is a doc on expressions added by postgres
GitHub
ash_postgres/documentation/topics/postgres-expressions.md at main ·...
A postgresql datalayer for the Ash Framework. Contribute to ash-project/ash_postgres development by creating an account on GitHub.
not deployed to ash-hq yet, will go out w/ the next release
It has
fragment
like
, ilike
and trigram_similarity