Liking cljdoc? Tell your friends :D

konserve.indexeddb


connect-idb-storecljs

(connect-idb-store db-name & {:as params})

Connect to a IndexedDB backed KV store with the given db name.

This implementation stores all values as js/Blobs in an IndexedDB object store instance. The object store itself is nameless, and there is no use of versioning, indexing, or cursors.

This data is stored as if indexedDB was a filesystem. Since we do not have file-descriptors to write with, strategy is to build a blob from components (js/Blobs have a nice api explicitly for this) and flush the blob to indexeddb storage on -sync-store calls (which doesnt concern consumers)

  • all store ops are asynchronous only

  • the database object must be 'unref'ed by calling db.close() before database instances can be deleted. You can do this easily by calling store.close() object method, which is unique to this impl. If you fail to maintain access to db and core.async gets into a weird state due to an unhandled error, you will be unable to delete the database until the vm is restarted

  • As of November 2023 firefox does not support IDBFactory.databases() so expect list-dbs, db-exists?, & PBackingStore/-store-exists? to all throw. You must work around this by keeping track of each db name you intend to delete https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/databases#browser_compatibility

  • konserve.core/bget locked-cb arg is given a webstream that is not queued to the value offset in the same way that the filestore implementations are. See: https://developer.mozilla.org/en-US/docs/Web/API/Blob/stream

    • consumers must discard the amount of bytes found in the :offset key of the locked-cb arg map. These bytes are meta data for konserve and not part of the value you are retrieving
    • konserve.indexeddb/read-web-stream will accept the argument to the locked-cb and return a promise-chan receiving err|bytes at the cost of allocating a larger array for the chunks to be copied into
Connect to a IndexedDB backed KV store with the given db name.

This implementation stores all values as js/Blobs in an IndexedDB
object store instance. The object store itself is nameless, and there
is no use of versioning, indexing, or cursors.

This data is stored as if indexedDB was a filesystem. Since we do not have
file-descriptors to write with, strategy is to build a blob from components
(js/Blobs have a nice api explicitly for this) and flush the blob to
indexeddb storage on -sync-store calls (which doesnt concern consumers)

+ all store ops are asynchronous only

+ the database object must be 'unref'ed by calling db.close() before database
instances can be deleted. You can do this easily by calling store.close()
object method, which is unique to this impl. If you fail to maintain access to
db and core.async gets into a weird state due to an unhandled error, you
will be unable to delete the database until the vm is restarted

+ As of November 2023 firefox does not support IDBFactory.databases() so
expect list-dbs, db-exists?, & PBackingStore/-store-exists? to all throw. You
must work around this by keeping track of each db name you intend to delete
https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/databases#browser_compatibility

+ `konserve.core/bget` locked-cb arg is given a webstream that is *not* queued
to the value offset in the same way that the filestore implementations are.
See: https://developer.mozilla.org/en-US/docs/Web/API/Blob/stream
  - consumers must discard the amount of bytes found in the :offset key of
    the locked-cb arg map. These bytes are meta data for konserve and not
    part of the value you are retrieving
  - `konserve.indexeddb/read-web-stream` will accept the argument to the
    locked-cb and return a promise-chan receiving err|bytes at the cost of
    allocating a larger array for the chunks to be copied into
sourceraw docstring

connect-to-idbcljs

(connect-to-idb db-name)
source

db-exists?cljs

(db-exists? db-name)
source

delete-idbcljs

(delete-idb db-name)
source

flush-blobcljs

(flush-blob {:keys [db key buf header metadata value]})
source

list-dbscljs

(list-dbs)
source

multi-delete-blobscljs

(multi-delete-blobs db store-keys)

Execute multiple delete operations in a single IndexedDB transaction. All operations either succeed or all fail (atomic). Returns a map of store-keys to boolean indicating if the blob existed.

Execute multiple delete operations in a single IndexedDB transaction.
All operations either succeed or all fail (atomic).
Returns a map of store-keys to boolean indicating if the blob existed.
sourceraw docstring

multi-read-blobscljs

(multi-read-blobs db store-keys)

Execute multiple read operations in a single IndexedDB transaction. Returns a sparse map of {store-key -> BackingBlob} for found keys only. Missing keys are excluded from the result map.

Execute multiple read operations in a single IndexedDB transaction.
Returns a sparse map of {store-key -> BackingBlob} for found keys only.
Missing keys are excluded from the result map.
sourceraw docstring

multi-write-blobscljs

(multi-write-blobs db store-key-values)

Execute multiple write operations in a single IndexedDB transaction. All operations either succeed or all fail (atomic).

Execute multiple write operations in a single IndexedDB transaction.
All operations either succeed or all fail (atomic).
sourceraw docstring

open-backing-blobcljs

(open-backing-blob db key)
source

read-blobcljs

(read-blob db key)
source

read-web-streamcljs

(read-web-stream {:keys [input-stream offset]})

Accepts the bget locked callback arg and returns a promise-chan containing a concatenated byte array with the first offset bytes dropped (k/bget store :key read-web-stream)

Accepts the bget locked callback arg and returns a promise-chan containing
a concatenated byte array with the first offset bytes dropped
`(k/bget store :key read-web-stream)`
sourceraw docstring

write-blobcljs

(write-blob db key blob)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close