<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="ExDoc v0.31.1"> <meta name="project" content="Plausible v0.0.1"> <title>Plausible.ClickhouseRepo — Plausible v0.0.1</title> <link rel="stylesheet" href="dist/html-elixir-FM2CSD74.css" /> <script src="dist/handlebars.runtime-NWIB6V2M.js"></script> <script src="dist/handlebars.templates-43PMFBC7.js"></script> <script src="dist/sidebar_items-D15B3CF1.js"></script> <script src="docs_config.js"></script> <script async src="dist/html-L4O5OK2K.js"></script> </head> <body data-type="modules" class="page-module"> <script> try { var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}'); if (settings.theme === 'dark' || ((settings.theme === 'system' || settings.theme == null) && window.matchMedia('(prefers-color-scheme: dark)').matches) ) { document.body.classList.add('dark') } } catch (error) { } </script> <div class="main"> <button id="sidebar-menu" class="sidebar-button sidebar-toggle" aria-label="toggle sidebar" aria-controls="sidebar"> <i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i> </button> <div class="background-layer"></div> <nav id="sidebar" class="sidebar"> <div class="sidebar-header"> <div class="sidebar-projectInfo"> <a href="readme.html" class="sidebar-projectImage"> <img src="assets/logo.png" alt="Plausible" /> </a> <div> <a href="readme.html" class="sidebar-projectName" translate="no"> Plausible </a> <div class="sidebar-projectVersion" translate="no"> v0.0.1 </div> </div> </div> <ul id="sidebar-listNav" class="sidebar-listNav" role="tablist"> <li> <button id="extras-list-tab-button" role="tab" data-type="extras" aria-controls="extras-tab-panel" aria-selected="true" tabindex="0"> Pages </button> </li> <li> <button id="modules-list-tab-button" role="tab" data-type="modules" aria-controls="modules-tab-panel" aria-selected="false" tabindex="-1"> Modules </button> </li> <li> <button id="tasks-list-tab-button" role="tab" data-type="tasks" aria-controls="tasks-tab-panel" aria-selected="false" tabindex="-1"> <span translate="no">Mix</span> Tasks </button> </li> </ul> </div> <div id="extras-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="extras-list-tab-button"> <ul id="extras-full-list" class="full-list"></ul> </div> <div id="modules-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="modules-list-tab-button" hidden> <ul id="modules-full-list" class="full-list"></ul> </div> <div id="tasks-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="tasks-list-tab-button" hidden> <ul id="tasks-full-list" class="full-list"></ul> </div> </nav> <main class="content"> <output role="status" id="toast"></output> <div class="content-outer"> <div id="content" class="content-inner"> <div class="top-search"> <div class="search-settings"> <form class="search-bar" action="search.html"> <label class="search-label"> <span class="sr-only">Search documentation of Plausible</span> <input name="q" type="text" class="search-input" placeholder="Search Documentation (press /)" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /> </label> <button type="submit" class="search-button" aria-label="Submit Search"> <i class="ri-search-2-line ri-lg" aria-hidden="true" title="Submit search"></i> </button> <button type="button" tabindex="-1" class="search-close-button" aria-hidden="true"> <i class="ri-close-line ri-lg" title="Cancel search"></i> </button> </form> <div class="autocomplete"> </div> <button class="icon-settings display-settings"> <i class="ri-settings-3-line"></i> <span class="sr-only">Settings</span> </button> </div> </div> <h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" title="View Source" class="icon-action" rel="help"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> <span translate="no">Plausible.ClickhouseRepo</span> <small class="app-vsn" translate="no">(Plausible v0.0.1)</small> </h1> <section id="summary" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#summary"> <i class="ri-link-m" aria-hidden="true"></i> </a> <span class="text">Summary</span> </h1> <div class="summary-functions summary"> <h2> <a href="#functions">Functions</a> </h2> <div class="summary-row"> <div class="summary-signature"> <a href="#aggregate/3" translate="no">aggregate(queryable, aggregate, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:aggregate/3"><code class="inline">Ecto.Repo.aggregate/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#aggregate/4" translate="no">aggregate(queryable, aggregate, field, opts)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:aggregate/4"><code class="inline">Ecto.Repo.aggregate/4</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#all/2" translate="no">all(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:all/2"><code class="inline">Ecto.Repo.all/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#checked_out?/0" translate="no">checked_out?()</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:checked_out?/0"><code class="inline">Ecto.Repo.checked_out?/0</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#checkout/2" translate="no">checkout(fun, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:checkout/2"><code class="inline">Ecto.Repo.checkout/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#child_spec/1" translate="no">child_spec(opts)</a> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#config/0" translate="no">config()</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:config/0"><code class="inline">Ecto.Repo.config/0</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#default_options/1" translate="no">default_options(operation)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:default_options/1"><code class="inline">Ecto.Repo.default_options/1</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#disconnect_all/2" translate="no">disconnect_all(interval, opts \\ [])</a> </div> <div class="summary-synopsis"><p>A convenience function for SQL-based repositories that forces all connections in the pool to disconnect within the given interval.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#exists?/2" translate="no">exists?(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:exists?/2"><code class="inline">Ecto.Repo.exists?/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#get/3" translate="no">get(queryable, id, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get/3"><code class="inline">Ecto.Repo.get/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#get!/3" translate="no">get!(queryable, id, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get!/3"><code class="inline">Ecto.Repo.get!/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#get_by/3" translate="no">get_by(queryable, clauses, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_by/3"><code class="inline">Ecto.Repo.get_by/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#get_by!/3" translate="no">get_by!(queryable, clauses, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_by!/3"><code class="inline">Ecto.Repo.get_by!/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#get_dynamic_repo/0" translate="no">get_dynamic_repo()</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_dynamic_repo/0"><code class="inline">Ecto.Repo.get_dynamic_repo/0</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#insert_stream/3" translate="no">insert_stream(source_or_schema, rows, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Similar to <code class="inline">insert_all/2</code> but with the following differences</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#load/2" translate="no">load(schema_or_types, data)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:load/2"><code class="inline">Ecto.Repo.load/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#one/2" translate="no">one(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:one/2"><code class="inline">Ecto.Repo.one/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#one!/2" translate="no">one!(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:one!/2"><code class="inline">Ecto.Repo.one!/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#parallel_tasks/1" translate="no">parallel_tasks(queries)</a> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#preload/3" translate="no">preload(struct_or_structs_or_nil, preloads, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:preload/3"><code class="inline">Ecto.Repo.preload/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#prepare_query/3" translate="no">prepare_query(operation, query, opts)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:prepare_query/3"><code class="inline">Ecto.Repo.prepare_query/3</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#put_dynamic_repo/1" translate="no">put_dynamic_repo(dynamic)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:put_dynamic_repo/1"><code class="inline">Ecto.Repo.put_dynamic_repo/1</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#query/3" translate="no">query(sql, params \\ [], opts \\ [])</a> </div> <div class="summary-synopsis"><p>A convenience function for SQL-based repositories that executes the given query.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#query!/3" translate="no">query!(sql, params \\ [], opts \\ [])</a> </div> <div class="summary-synopsis"><p>A convenience function for SQL-based repositories that executes the given query.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#reload/2" translate="no">reload(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:reload/2"><code class="inline">Ecto.Repo.reload/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#reload!/2" translate="no">reload!(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:reload!/2"><code class="inline">Ecto.Repo.reload!/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#start_link/1" translate="no">start_link(opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:start_link/1"><code class="inline">Ecto.Repo.start_link/1</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#stop/1" translate="no">stop(timeout \\ 5000)</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:stop/1"><code class="inline">Ecto.Repo.stop/1</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#stream/2" translate="no">stream(queryable, opts \\ [])</a> </div> <div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:stream/2"><code class="inline">Ecto.Repo.stream/2</code></a>.</p></div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#to_sql/2" translate="no">to_sql(operation, queryable)</a> </div> <div class="summary-synopsis"><p>A convenience function for SQL-based repositories that translates the given query to SQL.</p></div> </div> </div> </section> <section id="functions" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#functions"> <i class="ri-link-m" aria-hidden="true"></i> </a> <span class="text">Functions</span> </h1> <div class="functions-list"> <section class="detail" id="aggregate/3"> <span id="aggregate/2"></span> <div class="detail-header"> <a href="#aggregate/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">aggregate(queryable, aggregate, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:aggregate/3"><code class="inline">Ecto.Repo.aggregate/3</code></a>.</p> </section> </section> <section class="detail" id="aggregate/4"> <div class="detail-header"> <a href="#aggregate/4" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">aggregate(queryable, aggregate, field, opts)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:aggregate/4"><code class="inline">Ecto.Repo.aggregate/4</code></a>.</p> </section> </section> <section class="detail" id="all/2"> <span id="all/1"></span> <div class="detail-header"> <a href="#all/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">all(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:all/2"><code class="inline">Ecto.Repo.all/2</code></a>.</p> </section> </section> <section class="detail" id="checked_out?/0"> <div class="detail-header"> <a href="#checked_out?/0" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">checked_out?()</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:checked_out?/0"><code class="inline">Ecto.Repo.checked_out?/0</code></a>.</p> </section> </section> <section class="detail" id="checkout/2"> <span id="checkout/1"></span> <div class="detail-header"> <a href="#checkout/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">checkout(fun, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:checkout/2"><code class="inline">Ecto.Repo.checkout/2</code></a>.</p> </section> </section> <section class="detail" id="child_spec/1"> <div class="detail-header"> <a href="#child_spec/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">child_spec(opts)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> </section> </section> <section class="detail" id="config/0"> <div class="detail-header"> <a href="#config/0" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">config()</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:config/0"><code class="inline">Ecto.Repo.config/0</code></a>.</p> </section> </section> <section class="detail" id="default_options/1"> <div class="detail-header"> <a href="#default_options/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">default_options(operation)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:default_options/1"><code class="inline">Ecto.Repo.default_options/1</code></a>.</p> </section> </section> <section class="detail" id="disconnect_all/2"> <span id="disconnect_all/1"></span> <div class="detail-header"> <a href="#disconnect_all/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">disconnect_all(interval, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>A convenience function for SQL-based repositories that forces all connections in the pool to disconnect within the given interval.</p><p>See <a href="https://hexdocs.pm/ecto_sql/3.11.1/Ecto.Adapters.SQL.html#disconnect_all/3"><code class="inline">Ecto.Adapters.SQL.disconnect_all/3</code></a> for more information.</p> </section> </section> <section class="detail" id="exists?/2"> <span id="exists?/1"></span> <div class="detail-header"> <a href="#exists?/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">exists?(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:exists?/2"><code class="inline">Ecto.Repo.exists?/2</code></a>.</p> </section> </section> <section class="detail" id="get/3"> <span id="get/2"></span> <div class="detail-header"> <a href="#get/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">get(queryable, id, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get/3"><code class="inline">Ecto.Repo.get/3</code></a>.</p> </section> </section> <section class="detail" id="get!/3"> <span id="get!/2"></span> <div class="detail-header"> <a href="#get!/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">get!(queryable, id, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get!/3"><code class="inline">Ecto.Repo.get!/3</code></a>.</p> </section> </section> <section class="detail" id="get_by/3"> <span id="get_by/2"></span> <div class="detail-header"> <a href="#get_by/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">get_by(queryable, clauses, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_by/3"><code class="inline">Ecto.Repo.get_by/3</code></a>.</p> </section> </section> <section class="detail" id="get_by!/3"> <span id="get_by!/2"></span> <div class="detail-header"> <a href="#get_by!/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">get_by!(queryable, clauses, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_by!/3"><code class="inline">Ecto.Repo.get_by!/3</code></a>.</p> </section> </section> <section class="detail" id="get_dynamic_repo/0"> <div class="detail-header"> <a href="#get_dynamic_repo/0" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">get_dynamic_repo()</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:get_dynamic_repo/0"><code class="inline">Ecto.Repo.get_dynamic_repo/0</code></a>.</p> </section> </section> <section class="detail" id="insert_stream/3"> <span id="insert_stream/2"></span> <div class="detail-header"> <a href="#insert_stream/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">insert_stream(source_or_schema, rows, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Similar to <code class="inline">insert_all/2</code> but with the following differences:</p><ul><li>accepts rows as streams or lists</li><li>sends rows as a chunked request</li><li>doesn't autogenerate ids or does any other preprocessing</li></ul><p>Example:</p><pre><code class="makeup elixir" translate="no"><span class="nc">Repo</span><span class="o">.</span><span class="n">query!</span><span class="p" data-group-id="8205552621-1">(</span><span class="s">"create table ecto_ch_demo(a UInt64, b String) engine Null"</span><span class="p" data-group-id="8205552621-1">)</span><span class="w"> </span><span class="kd">defmodule</span><span class="w"> </span><span class="nc">Demo</span><span class="w"> </span><span class="k" data-group-id="8205552621-2">do</span><span class="w"> </span><span class="kn">use</span><span class="w"> </span><span class="nc">Ecto.Schema</span><span class="w"> </span><span class="na">@primary_key</span><span class="w"> </span><span class="no">false</span><span class="w"> </span><span class="n">schema</span><span class="w"> </span><span class="s">"ecto_ch_demo"</span><span class="w"> </span><span class="k" data-group-id="8205552621-3">do</span><span class="w"> </span><span class="n">field</span><span class="w"> </span><span class="ss">:a</span><span class="p">,</span><span class="w"> </span><span class="nc">Ch</span><span class="p">,</span><span class="w"> </span><span class="ss">type</span><span class="p">:</span><span class="w"> </span><span class="s">"UInt64"</span><span class="w"> </span><span class="n">field</span><span class="w"> </span><span class="ss">:b</span><span class="p">,</span><span class="w"> </span><span class="ss">:string</span><span class="w"> </span><span class="k" data-group-id="8205552621-3">end</span><span class="w"> </span><span class="k" data-group-id="8205552621-2">end</span><span class="w"> </span><span class="n">rows</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Stream</span><span class="o">.</span><span class="n">map</span><span class="p" data-group-id="8205552621-4">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">100_000</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="8205552621-5">fn</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="p" data-group-id="8205552621-6">%{</span><span class="ss">a</span><span class="p">:</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="ss">b</span><span class="p">:</span><span class="w"> </span><span class="n">to_string</span><span class="p" data-group-id="8205552621-7">(</span><span class="n">i</span><span class="p" data-group-id="8205552621-7">)</span><span class="p" data-group-id="8205552621-6">}</span><span class="w"> </span><span class="k" data-group-id="8205552621-5">end</span><span class="p" data-group-id="8205552621-4">)</span><span class="w"> </span><span class="p" data-group-id="8205552621-8">{</span><span class="mi">100_000</span><span class="p">,</span><span class="w"> </span><span class="no">nil</span><span class="p" data-group-id="8205552621-8">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Repo</span><span class="o">.</span><span class="n">insert_stream</span><span class="p" data-group-id="8205552621-9">(</span><span class="nc">Demo</span><span class="p">,</span><span class="w"> </span><span class="n">rows</span><span class="p" data-group-id="8205552621-9">)</span><span class="w"> </span><span class="c1"># schemaless</span><span class="w"> </span><span class="p" data-group-id="8205552621-10">{</span><span class="mi">100_000</span><span class="p">,</span><span class="w"> </span><span class="no">nil</span><span class="p" data-group-id="8205552621-10">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Repo</span><span class="o">.</span><span class="n">insert_stream</span><span class="p" data-group-id="8205552621-11">(</span><span class="s">"ecto_ch_demo"</span><span class="p">,</span><span class="w"> </span><span class="n">rows</span><span class="p">,</span><span class="w"> </span><span class="ss">types</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="8205552621-12">[</span><span class="ss">a</span><span class="p">:</span><span class="w"> </span><span class="nc">Ch.Types</span><span class="o">.</span><span class="n">u64</span><span class="p" data-group-id="8205552621-13">(</span><span class="p" data-group-id="8205552621-13">)</span><span class="p">,</span><span class="w"> </span><span class="ss">b</span><span class="p">:</span><span class="w"> </span><span class="ss">:string</span><span class="p" data-group-id="8205552621-12">]</span><span class="p" data-group-id="8205552621-11">)</span></code></pre> </section> </section> <section class="detail" id="load/2"> <div class="detail-header"> <a href="#load/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">load(schema_or_types, data)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:load/2"><code class="inline">Ecto.Repo.load/2</code></a>.</p> </section> </section> <section class="detail" id="one/2"> <span id="one/1"></span> <div class="detail-header"> <a href="#one/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">one(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:one/2"><code class="inline">Ecto.Repo.one/2</code></a>.</p> </section> </section> <section class="detail" id="one!/2"> <span id="one!/1"></span> <div class="detail-header"> <a href="#one!/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">one!(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:one!/2"><code class="inline">Ecto.Repo.one!/2</code></a>.</p> </section> </section> <section class="detail" id="parallel_tasks/1"> <div class="detail-header"> <a href="#parallel_tasks/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">parallel_tasks(queries)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L16" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> </section> </section> <section class="detail" id="preload/3"> <span id="preload/2"></span> <div class="detail-header"> <a href="#preload/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">preload(struct_or_structs_or_nil, preloads, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:preload/3"><code class="inline">Ecto.Repo.preload/3</code></a>.</p> </section> </section> <section class="detail" id="prepare_query/3"> <div class="detail-header"> <a href="#prepare_query/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">prepare_query(operation, query, opts)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:prepare_query/3"><code class="inline">Ecto.Repo.prepare_query/3</code></a>.</p> </section> </section> <section class="detail" id="put_dynamic_repo/1"> <div class="detail-header"> <a href="#put_dynamic_repo/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">put_dynamic_repo(dynamic)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:put_dynamic_repo/1"><code class="inline">Ecto.Repo.put_dynamic_repo/1</code></a>.</p> </section> </section> <section class="detail" id="query/3"> <span id="query/1"></span> <span id="query/2"></span> <div class="detail-header"> <a href="#query/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">query(sql, params \\ [], opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>A convenience function for SQL-based repositories that executes the given query.</p><p>See <a href="https://hexdocs.pm/ecto_sql/3.11.1/Ecto.Adapters.SQL.html#query/4"><code class="inline">Ecto.Adapters.SQL.query/4</code></a> for more information.</p> </section> </section> <section class="detail" id="query!/3"> <span id="query!/1"></span> <span id="query!/2"></span> <div class="detail-header"> <a href="#query!/3" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">query!(sql, params \\ [], opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>A convenience function for SQL-based repositories that executes the given query.</p><p>See <a href="https://hexdocs.pm/ecto_sql/3.11.1/Ecto.Adapters.SQL.html#query!/4"><code class="inline">Ecto.Adapters.SQL.query!/4</code></a> for more information.</p> </section> </section> <section class="detail" id="reload/2"> <span id="reload/1"></span> <div class="detail-header"> <a href="#reload/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">reload(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:reload/2"><code class="inline">Ecto.Repo.reload/2</code></a>.</p> </section> </section> <section class="detail" id="reload!/2"> <span id="reload!/1"></span> <div class="detail-header"> <a href="#reload!/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">reload!(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:reload!/2"><code class="inline">Ecto.Repo.reload!/2</code></a>.</p> </section> </section> <section class="detail" id="start_link/1"> <span id="start_link/0"></span> <div class="detail-header"> <a href="#start_link/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">start_link(opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:start_link/1"><code class="inline">Ecto.Repo.start_link/1</code></a>.</p> </section> </section> <section class="detail" id="stop/1"> <span id="stop/0"></span> <div class="detail-header"> <a href="#stop/1" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">stop(timeout \\ 5000)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:stop/1"><code class="inline">Ecto.Repo.stop/1</code></a>.</p> </section> </section> <section class="detail" id="stream/2"> <span id="stream/1"></span> <div class="detail-header"> <a href="#stream/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">stream(queryable, opts \\ [])</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L2" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Callback implementation for <a href="https://hexdocs.pm/ecto/3.11.1/Ecto.Repo.html#c:stream/2"><code class="inline">Ecto.Repo.stream/2</code></a>.</p> </section> </section> <section class="detail" id="to_sql/2"> <div class="detail-header"> <a href="#to_sql/2" class="detail-link" title="Link to this function"> <i class="ri-link-m" aria-hidden="true"></i> <span class="sr-only">Link to this function</span> </a> <h1 class="signature" translate="no">to_sql(operation, queryable)</h1> <a href="https://github.com/plausible/analytics/blob/main/lib/plausible/clickhouse_repo.ex#L1" class="icon-action" rel="help" title="View Source"> <i class="ri-code-s-slash-line" aria-hidden="true"></i> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>A convenience function for SQL-based repositories that translates the given query to SQL.</p><p>See <a href="https://hexdocs.pm/ecto_sql/3.11.1/Ecto.Adapters.SQL.html#to_sql/3"><code class="inline">Ecto.Adapters.SQL.to_sql/3</code></a> for more information.</p> </section> </section> </div> </section> <footer class="footer"> <p> <span class="line"> <button class="a-main footer-button display-quick-switch" title="Search HexDocs packages"> Search HexDocs </button> <a href="Plausible.epub" title="ePub version"> Download ePub version </a> </span> </p> <p class="built-using"> Built using <a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v0.31.1) for the <a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a> </p> </footer> </div> </div> </main> </div> <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> <script>mermaid.initialize({startOnLoad: true})</script> </body> </html>