Skip to content

Commit 24e853e

Browse files
committed
[docs] Bump
1 parent 0b0bce9 commit 24e853e

22 files changed

Lines changed: 10580 additions & 18006 deletions

File tree

coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"tests":7064,"assertions":32743,"lines":{"total":2289,"covered":2289,"skipped":0,"pct":100},"statements":{"total":2473,"covered":2473,"skipped":0,"pct":100},"functions":{"total":988,"covered":988,"skipped":0,"pct":100},"branches":{"total":854,"covered":854,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
1+
{"tests":7064,"assertions":32744,"lines":{"total":2289,"covered":2289,"skipped":0,"pct":100},"statements":{"total":2473,"covered":2473,"skipped":0,"pct":100},"functions":{"total":988,"covered":988,"skipped":0,"pct":100},"branches":{"total":854,"covered":854,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}

docs/api/all.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

docs/api/persister-electric-sql/functions/creation/createelectricsqlpersister/article.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

docs/api/persister-electric-sql/functions/creation/createelectricsqlpersister/index.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

docs/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/article.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/api/">API</a></li><li><a href="/api/persister-electric-sql/"><code>persister-electric-sql</code></a></li><li><a href="/api/persister-electric-sql/interfaces/">Interfaces</a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/"><code>ElectricSqlPersister</code></a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/">Getter methods</a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/"><code>getElectricClient</code></a></li></ul></nav><section class="s1" id="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/" data-id="gEC"><h1><code>getElectricClient</code></h1><p>The <code>getElectricClient</code> method returns a reference to the Electric client the <a href="/api/store/interfaces/store/store/"><code>Store</code></a> is being persisted to.</p><pre><code><span class="function"><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/">getElectricClient</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="operator">:</span> ElectricClient<span class="operator">&lt;</span><span class="builtin">any</span><span class="operator">></span></code></pre><div class="table"><table><tr><th class="right">returns</th><td><code>ElectricClient<span class="operator">&lt;</span><span class="builtin">any</span><span class="operator">></span></code></td><td><p></p><p>A reference to the Electric client.</p><p></p></td></tr></table></div><section class="s2"><h2>Example</h2><p>This example creates a <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> object against a newly-created <a href="/api/store/interfaces/store/store/"><code>Store</code></a> and then gets the Electric client back out again.</p><pre><code><span class="keyword">import</span> <span class="punctuation">{</span>schema<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'./generated/client'</span><span class="punctuation">;</span>
2-
<span class="keyword">import</span> <span class="punctuation">{</span>ElectricDatabase<span class="punctuation">,</span> electrify<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'electric-sql/wa-sqlite'</span><span class="punctuation">;</span>
1+
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/api/">API</a></li><li><a href="/api/persister-electric-sql/"><code>persister-electric-sql</code></a></li><li><a href="/api/persister-electric-sql/interfaces/">Interfaces</a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/"><code>ElectricSqlPersister</code></a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/">Getter methods</a></li><li><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/"><code>getElectricClient</code></a></li></ul></nav><section class="s1" id="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/" data-id="gEC"><h1><code>getElectricClient</code></h1><p>The <code>getElectricClient</code> method returns a reference to the Electric client the <a href="/api/store/interfaces/store/store/"><code>Store</code></a> is being persisted to.</p><pre><code><span class="function"><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/">getElectricClient</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="operator">:</span> ElectricClient<span class="operator">&lt;</span><span class="builtin">any</span><span class="operator">></span></code></pre><div class="table"><table><tr><th class="right">returns</th><td><code>ElectricClient<span class="operator">&lt;</span><span class="builtin">any</span><span class="operator">></span></code></td><td><p></p><p>A reference to the Electric client.</p><p></p></td></tr></table></div><section class="s2"><h2>Example</h2><p>This example creates a <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> object against a newly-created <a href="/api/store/interfaces/store/store/"><code>Store</code></a> and then gets the Electric client back out again.</p><pre><code><span class="keyword">import</span> <span class="punctuation">{</span>ElectricDatabase<span class="punctuation">,</span> electrify<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'electric-sql/wa-sqlite'</span><span class="punctuation">;</span>
32
<span class="keyword">import</span> <span class="punctuation">{</span>createStore<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase'</span><span class="punctuation">;</span>
43
<span class="keyword">import</span> <span class="punctuation">{</span>createElectricSqlPersister<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase/persisters/persister-electric-sql'</span><span class="punctuation">;</span>
4+
<span class="keyword">import</span> <span class="punctuation">{</span>schema<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'./generated/client'</span><span class="punctuation">;</span>
55

66
<span class="keyword">const</span> electricClient <span class="operator">=</span> <span class="keyword">await</span> <span class="function">electrify</span><span class="punctuation">(</span>
77
<span class="keyword">await</span> ElectricDatabase<span class="punctuation">.</span><span class="function">init</span><span class="punctuation">(</span><span class="string">'electric.db'</span><span class="punctuation">,</span> <span class="string">''</span><span class="punctuation">)</span><span class="punctuation">,</span>

docs/api/persister-electric-sql/interfaces/persister/electricsqlpersister/methods/getter/getelectricclient/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/demos/article.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/demos/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/guides/persistence/database-persistence/article.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/guides/">Guides</a></li><li><a href="/guides/persistence/">Persistence</a></li><li><a href="/guides/persistence/database-persistence/">Database Persistence</a></li></ul></nav><section class="s1" id="/guides/persistence/database-persistence/" data-id="DP"><h1>Database Persistence</h1><p>Since v4.0, there are various options for persisting <a href="/api/store/interfaces/store/store/"><code>Store</code></a> data to and from SQLite databases, via a range of third-party modules.</p><p>There are currently seven SQLite-based persistence options, and two for PostgreSQL:</p><div class="table"><table><thead><tr><th><a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a></th><th>Storage</th></tr></thead><tbody><tr><td><a href="/api/persister-sqlite3/interfaces/persister/sqlite3persister/"><code>Sqlite3Persister</code></a></td><td>SQLite in Node, via <a href="https://github.com/TryGhost/node-sqlite3">sqlite3</a></td></tr><tr><td><a href="/api/persister-sqlite-wasm/interfaces/persister/sqlitewasmpersister/"><code>SqliteWasmPersister</code></a></td><td>SQLite in a browser, via <a href="https://github.com/tomayac/sqlite-wasm">sqlite-wasm</a></td></tr><tr><td><a href="/api/persister-expo-sqlite/interfaces/persister/exposqlitepersister/"><code>ExpoSqlitePersister</code></a></td><td>SQLite in React Native, via <a href="https://github.com/expo/expo/tree/main/packages/expo-sqlite">expo-sqlite</a></td></tr><tr><td><a href="/api/persister-cr-sqlite-wasm/interfaces/persister/crsqlitewasmpersister/"><code>CrSqliteWasmPersister</code></a></td><td>SQLite CRDTs, via <a href="https://github.com/vlcn-io/cr-sqlite">cr-sqlite-wasm</a></td></tr><tr><td><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/"><code>ElectricSqlPersister</code></a></td><td>Electric SQL, via <a href="https://github.com/electric-sql/electric">electric</a></td></tr><tr><td><a href="/api/persister-libsql/interfaces/persister/libsqlpersister/"><code>LibSqlPersister</code></a></td><td>LibSQL for Turso, via <a href="https://github.com/tursodatabase/libsql-client-ts">libsql-client</a></td></tr><tr><td><a href="/api/persister-powersync/interfaces/persister/powersyncpersister/"><code>PowerSyncPersister</code></a></td><td>PowerSync, via <a href="https://github.com/powersync-ja/powersync-js">powersync-sdk</a></td></tr><tr><td><a href="/api/persister-postgres/interfaces/persister/postgrespersister/"><code>PostgresPersister</code></a></td><td>PostgreSQL, via <a href="https://github.com/porsager/postgres">postgres</a></td></tr><tr><td><a href="/api/persister-pglite/interfaces/persister/pglitepersister/"><code>PglitePersister</code></a></td><td>PostgreSQL, via <a href="https://github.com/electric-sql/pglite">PGlite</a></td></tr></tbody></table></div><p>(Take a look at the <a href="https://github.com/tinyplex/vite-tinybase-ts-react-crsqlite">vite-tinybase-ts-react-crsqlite</a> template, for example, which demonstrates Vulcan&#x27;s cr-sqlite to provide persistence and synchronization via the third of these.)</p><p>Each creation function takes a database reference, and a <a href="/api/persisters/type-aliases/configuration/databasepersisterconfig/"><code>DatabasePersisterConfig</code></a> object to describe its configuration. There are two modes for persisting a <a href="/api/store/interfaces/store/store/"><code>Store</code></a> with a database:</p><ul><li>A JSON serialization of the whole <a href="/api/store/interfaces/store/store/"><code>Store</code></a>, which is stored in a single row of a table (normally called <code>tinybase</code>) within the database. This is configured by providing a <a href="/api/persisters/type-aliases/configuration/dpcjson/"><code>DpcJson</code></a> object.</li><li>A tabular mapping of <a href="/api/store/type-aliases/store/table/"><code>Table</code></a> <a href="/api/common/type-aliases/identity/ids/"><code>Ids</code></a> to database table names (and vice-versa). <a href="/api/store/type-aliases/store/values/"><code>Values</code></a> are stored in a separate special table (normally called <code>tinybase_values</code>). This is configured by providing a <a href="/api/persisters/type-aliases/configuration/dpctabular/"><code>DpcTabular</code></a> object.</li></ul><p>Note that changes made to the database (outside of a <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>) are picked up immediately if they are made via the same connection or library that it is using. If the database is being changed by another client, the <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> needs to poll for changes. Hence both configuration types also contain an <code>autoLoadIntervalSeconds</code> property which indicates how often it should do that. This defaults to 1 second.</p><h3 id="using-json-serialization">Using JSON Serialization</h3><p>To get started, we&#x27;ll use JSON serialization to save a <a href="/api/store/interfaces/store/store/"><code>Store</code></a> to SQLite in the browser, via the <a href="https://github.com/tomayac/sqlite-wasm">sqlite-wasm</a> module.</p><p>Firstly, use the module to initiate a database. Here it will be created in memory, but typically you would use the origin private file system (OPFS) as a storage back-end.</p><pre><code><span class="keyword">import</span> sqlite3InitModule <span class="keyword">from</span> <span class="string">'@sqlite.org/sqlite-wasm'</span><span class="punctuation">;</span>
1+
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/guides/">Guides</a></li><li><a href="/guides/persistence/">Persistence</a></li><li><a href="/guides/persistence/database-persistence/">Database Persistence</a></li></ul></nav><section class="s1" id="/guides/persistence/database-persistence/" data-id="DP"><h1>Database Persistence</h1><p>Since v4.0, there are various options for persisting <a href="/api/store/interfaces/store/store/"><code>Store</code></a> data to and from SQLite databases, via a range of third-party modules.</p><p>There are currently seven SQLite-based persistence options, and two for PostgreSQL:</p><div class="table"><table><thead><tr><th><a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a></th><th>Storage</th></tr></thead><tbody><tr><td><a href="/api/persister-sqlite3/interfaces/persister/sqlite3persister/"><code>Sqlite3Persister</code></a></td><td>SQLite in Node, via <a href="https://github.com/TryGhost/node-sqlite3">sqlite3</a></td></tr><tr><td><a href="/api/persister-sqlite-wasm/interfaces/persister/sqlitewasmpersister/"><code>SqliteWasmPersister</code></a></td><td>SQLite in a browser, via <a href="https://github.com/tomayac/sqlite-wasm">sqlite-wasm</a></td></tr><tr><td><a href="/api/persister-expo-sqlite/interfaces/persister/exposqlitepersister/"><code>ExpoSqlitePersister</code></a></td><td>SQLite in React Native, via <a href="https://github.com/expo/expo/tree/main/packages/expo-sqlite">expo-sqlite</a></td></tr><tr><td><a href="/api/persister-cr-sqlite-wasm/interfaces/persister/crsqlitewasmpersister/"><code>CrSqliteWasmPersister</code></a></td><td>SQLite CRDTs, via <a href="https://github.com/vlcn-io/cr-sqlite">cr-sqlite-wasm</a></td></tr><tr><td><a href="/api/persister-electric-sql/interfaces/persister/electricsqlpersister/"><code>ElectricSqlPersister</code></a></td><td>Electric SQL, via <a href="https://github.com/electric-sql/electric">electric</a></td></tr><tr><td><a href="/api/persister-libsql/interfaces/persister/libsqlpersister/"><code>LibSqlPersister</code></a></td><td>LibSQL for Turso, via <a href="https://github.com/tursodatabase/libsql-client-ts">libsql-client</a></td></tr><tr><td><a href="/api/persister-powersync/interfaces/persister/powersyncpersister/"><code>PowerSyncPersister</code></a></td><td>PowerSync, via <a href="https://github.com/powersync-ja/powersync-js">powersync-sdk</a></td></tr><tr><td><a href="/api/persister-postgres/interfaces/persister/postgrespersister/"><code>PostgresPersister</code></a></td><td>PostgreSQL, via <a href="https://github.com/porsager/postgres">postgres</a></td></tr><tr><td><a href="/api/persister-pglite/interfaces/persister/pglitepersister/"><code>PglitePersister</code></a></td><td>PostgreSQL, via <a href="https://github.com/electric-sql/pglite">PGlite</a></td></tr></tbody></table></div><p>Each creation function takes a database reference, and a <a href="/api/persisters/type-aliases/configuration/databasepersisterconfig/"><code>DatabasePersisterConfig</code></a> object to describe its configuration. There are two modes for persisting a <a href="/api/store/interfaces/store/store/"><code>Store</code></a> with a database:</p><ul><li>A JSON serialization of the whole <a href="/api/store/interfaces/store/store/"><code>Store</code></a>, which is stored in a single row of a table (normally called <code>tinybase</code>) within the database. This is configured by providing a <a href="/api/persisters/type-aliases/configuration/dpcjson/"><code>DpcJson</code></a> object.</li><li>A tabular mapping of <a href="/api/store/type-aliases/store/table/"><code>Table</code></a> <a href="/api/common/type-aliases/identity/ids/"><code>Ids</code></a> to database table names (and vice-versa). <a href="/api/store/type-aliases/store/values/"><code>Values</code></a> are stored in a separate special table (normally called <code>tinybase_values</code>). This is configured by providing a <a href="/api/persisters/type-aliases/configuration/dpctabular/"><code>DpcTabular</code></a> object.</li></ul><p>Note that changes made to the database (outside of a <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>) are picked up immediately if they are made via the same connection or library that it is using. If the database is being changed by another client, the <a href="/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> needs to poll for changes. Hence both configuration types also contain an <code>autoLoadIntervalSeconds</code> property which indicates how often it should do that. This defaults to 1 second.</p><h3 id="using-json-serialization">Using JSON Serialization</h3><p>To get started, we&#x27;ll use JSON serialization to save a <a href="/api/store/interfaces/store/store/"><code>Store</code></a> to SQLite in the browser, via the <a href="https://github.com/tomayac/sqlite-wasm">sqlite-wasm</a> module.</p><p>Firstly, use the module to initiate a database. Here it will be created in memory, but typically you would use the origin private file system (OPFS) as a storage back-end.</p><pre><code><span class="keyword">import</span> sqlite3InitModule <span class="keyword">from</span> <span class="string">'@sqlite.org/sqlite-wasm'</span><span class="punctuation">;</span>
22
<span class="keyword">import</span> <span class="punctuation">{</span>createStore<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase'</span><span class="punctuation">;</span>
33
<span class="keyword">import</span> <span class="punctuation">{</span>createSqliteWasmPersister<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase/persisters/persister-sqlite-wasm'</span><span class="punctuation">;</span>
44

0 commit comments

Comments
 (0)