Set `org_id` as a default for Repository operations
masterTo avoid manually passing org_id to every repository call, you can store the tenant ID in the process dictionary and use the default_options/1 callback to inject it automatically.
- Store the ID: Create
put_org_id/1andget_org_id/0functions in your Repo module that useProcess.put/2andProcess.get/1with a private@tenant_key. - Inject the ID: Implement
default_options/1to return[org_id: get_org_id()]. - Usage: Call
MyApp.Repo.put_org_id(id)at the start of a process (e.g., in a web request handler or a test setup).
@impl true
def default_options(_operation) do
[org_id: get_org_id()]
end