dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.62k stars 642 forks source link

Optimize Blobs and Files in Dexie Cloud #1860

Open dfahlander opened 10 months ago

dfahlander commented 10 months ago

Storing images, movies, tunes, sounds and files in IndexedDB is best accomplished by storing the data in Blob properties.

When using Dexie Cloud, Blobs are currently supported but they are stored in the SQL database on the backend in Base64 format. There are a few downsides with this:

This feature request is to optimize Blobs and Files specifically and store them in a Blob storage cloud service rather than the SQL database on the server. Since Blob and File are immutable, we won't need any specific support for updating contents within a Blob. If a Blob based property is changed, this will always lead to a new Blob being created.

Updated sync flow:

Server side CRUD operations

Client side CRUD operations

dusty-phillips commented 5 months ago

Suggestion: hash blobs such that if multiple copies of the same image are in a user’s db (maybe in different realms), you only have to store and sync it to the device once.

dfahlander commented 5 months ago

Suggestion: hash blobs such that if multiple copies of the same image are in a user’s db (maybe in different realms), you only have to store and sync it to the device once.

Thanks, it's probably a good idea but it puts some complexity in: If someone deletes a blob or even a whole DB that has references to it, we'd need to keep a ref-count to know when it would be safe to delete it. So I probably start out without this and add it later... Thanks for the suggestion!