Ash FrameworkAF
Ash Framework6mo ago
4 replies
Gonzalo Muñoz

Auxiliary Resources OK?

Hey guys, is this correct / good practice?

I have 3 main categories of knowledge: Facts, Methods (or recipes, techniques), and Preferences

I want to search across the three via a simple system of tags. I started with a free-form independent array of tags for each one of my main resources, but I ended up entangling myself, so I went ahead and created a Tags resource with many::many relationships in an attempt to be able to search all resources like so: ?filter[tags.name]=elixir.

But now I'm left with a lot of Resources that feel more like a workaround or a thin wrapper to a DB table instead of an accurate description of my domain:

fascicolo/lib/fascicolo/knowledge.ex
  resources do
    # "Real" resources for knowledge management:
    resource Fascicolo.Knowledge.Fact
    resource Fascicolo.Knowledge.Method
    resource Fascicolo.Knowledge.Preference

    # Virtual resource for search functionality:
    resource Fascicolo.Knowledge.Search

    # Shared Tag resource for all knowledge types:
    resource Fascicolo.Knowledge.Tag

    # Intermediate resources for many-to-many relationships:
    resource Fascicolo.Knowledge.FactTag
    resource Fascicolo.Knowledge.MethodTag
    resource Fascicolo.Knowledge.PreferenceTag
  end


Of these 8, I only really care about 3. Is this a normal architecture, or am I grossly misinterpreting the way Ash works?
Was this page helpful?