199 views
# Models [:mag: Incommon API domain models | Overview](https://framagit.org/incommon.cc/incommon-api/blob/develop/doc/diagrams/models_diagrams.svg) [TOC] ## Links between models :::warning :question: ::: ## Models - address - category - collection - email - link - location - map - phone - position - **resource** - entity - **agent** - place - thing - **role** - section - **taxonomy** - **user** * application ## Composition objects - resource_address - resource_collection - resource_email - resource_link - resource_phone - resource_section - user_email :::info https://pad.degrowth.net/s/incommon-api-addressing ::: ## Application models ### First order application models cat independent ``` address agent application_record email entity link phone place position service thing user ``` ### Second order application models cat dependent ``` category collection location map resource resource_address resource_collection resource_email resource_link resource_phone resource_section role section taxonomy user_email ``` ### All application models ```bash ls | rg ".rb" | cut -d. -f1 | sort -u > all rg "belongs_to " | rg .rb | cut -d. -f1 | sort -u > dependent diff all dependent | rg "^(<)" | cut -d" " -f2 > independent ``` cat all ``` address agent application_record category collection email entity link location map phone place position resource resource_address resource_collection resource_email resource_link resource_phone resource_section role section service taxonomy thing user user_email ``` ## Reverse application model hierarchy rg "(^class)" | cut -d: -f2 | sed "s/class //" ``` Address < ApplicationRecord Agent < Entity ApplicationRecord < ActiveRecord Collection < ApplicationRecord Category < ApplicationRecord Entity < Resource Link < ApplicationRecord Location < ApplicationRecord Map < ApplicationRecord Place < Resource Position < ApplicationRecord Resource < ApplicationRecord ResourceCollection < ApplicationRecord ResourceEmail < ApplicationRecord ResourceAddress < ApplicationRecord ResourcePhone < ApplicationRecord ResourceLink < ApplicationRecord ResourceSection < ApplicationRecord Role < ApplicationRecord Section < ApplicationRecord Service < Resource Taxonomy < ApplicationRecord Thing < Resource User < ApplicationRecord UserEmail < ApplicationRecord Phone < ApplicationRecord Email < ApplicationRecord ``` ## Approaching cd src/app/models rg "belongs_to: " ```ruby category.rb 8: belongs_to :taxonomy, counter_cache: true collection.rb 8: belongs_to :agent, class_name: 'Agent' location.rb 4: belongs_to :position 5: belongs_to :locatable, polymorphic: true map.rb 7: belongs_to :taxonomy 8: belongs_to :position 9: belongs_to :collection 10: belongs_to :agent resource.rb 10: belongs_to :agent, optional: true, class_name: 'Agent', inverse_of: :resources resource_address.rb 8: belongs_to :address 13: belongs_to :resource, polymorphic: true 14: belongs_to :agent, resource_collection.rb 4: belongs_to :resource, inverse_of: :resource_collections 5: belongs_to :collection, inverse_of: :resource_collections resource_email.rb 8: belongs_to :email 9: belongs_to :resource, polymorphic: true 12: belongs_to :agent, -> { where(resource_type: 'Agent') }, class_name: 'Agent', optional: true resource_link.rb 8: belongs_to :link 9: belongs_to :resource, polymorphic: true 11: belongs_to :agent, resource_phone.rb 8: belongs_to :phone 9: belongs_to :resource, polymorphic: true 11: belongs_to :agent, resource_section.rb 4: belongs_to :resource, polymorphic: true 5: belongs_to :section, counter_cache: true role.rb 6: belongs_to :user 7: belongs_to :agent section.rb 8: belongs_to :category, counter_cache: true taxonomy.rb 12: belongs_to :agent user_email.rb 4: belongs_to :email 5: belongs_to :user ```