You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This demo can be used to open databases in different storage implementations and
18
18
access modes (e.g. through shared or dedicated workers).
19
19
20
-
To open a database, open the consule and run <code>await open('name', 'storage', 'access')</code>.
21
-
Supported values for <code>storage</code> are:
20
+
To open a database, open the consule and run <code>await open('name', 'implementation')</code>.
21
+
Supported values for <code>implementation</code> are:
22
22
<ul>
23
-
<li><code>opfs</code>: Uses the <ahref="https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system">Origin private file system</a></li>
24
-
<li><code>indexedDb</code>: Uses a virtualized file system implemented by storing chunks in IndexedDB</li>
25
-
<li><code>inMemory</code>: Only stores files in memory without persistence.</li>
26
-
</ul>
27
-
28
-
Supported values for <code>access</code> are:
29
-
30
-
<ul>
31
-
<li><code>throughSharedWorker</code>: Open the database in a shared worker. Different tabs will use the same sqlite3 connection</li>
32
-
<li><code>throughDedicatedWorker</code>: Open the database in a dedicated worker. Requires shared array buffers when used with OPFS, and there is no synchronization for IndexedDB in dedicated workers.</li>
33
-
<li><code>inCurrentContext</code>: Open the database in the current context, without a worker</li>
23
+
<li><code>inMemoryLocal</code>: Only stores files in memory without persistence.</li>
24
+
<li><code>inMemoryShared</code>: In-memory database, but shared across tabs with a shared worker.</li>
25
+
<li><code>indexedDbUnsafeLocal</code>: Store data in IndexedDB, using each tab unisolated access to the database. Because data is just read once on startup, this is not a good file system implementation and prone to data corruption when used across multiple tabs.</li>
26
+
<li><code>indexedDbUnsafeWorker</code>: Like local, but in a shared worker.</li>
27
+
<li><code>indexedDbShared</code>: Safely store data in IndexedDB with a shared worker. Limited durability guarantees compared to OPFS.</li>
28
+
29
+
<li><code>opfsWithExternalLocks</code>: Uses the <ahref="https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system">Origin private file system</a>. This uses the experimental <code>readwrite-unsafe</code> mode only available on Chrome.</li>
30
+
<li><code>opfsAtomics</code>: OPFS storage, but uses a pair of dedicated workers using shared memory and atomics to syncify requests. This requires COOP + COEP headers.</li>
31
+
<li><code>opfsShared</code>: OPFS storage, using a dedicated worker in a shared worker. This is only supported on Firefox.</li>
34
32
</ul>
35
33
36
34
After opening a database, you can use <code>execute</code> in the console to run
37
35
SQL on it, e.g:
38
36
39
37
<code>
40
38
<pre>
41
-
let db = await open('test', 'inMemory', 'throughSharedWorker');
39
+
let db = await open('test', 'opfsWithExternalLocks');
0 commit comments