mergesort / Boutique

✨ A magical persistence library (and so much more) for state-driven iOS and Mac apps ✨
https://build.ms/boutique/docs
MIT License
899 stars 43 forks source link

Feature: automate saving blobs to disk with reference in store #55

Closed tal closed 10 months ago

tal commented 11 months ago

Since it's an antipattern to store large things in the database itself, I think there's room in the framework to automate the process of saving the blob off to a file on disk with a reference in the type stored in the database. This could automate the saving/inflating of the information and promote best practices while also following the ethos of making local persistence very easy.

mergesort commented 10 months ago

Hey @tal, thanks for the suggestion, it's something I'd like to have too. I wrote a little bit about this in #20 a while back (in the section titled Property wrapper for handling data/images), but I should create some dedicated space on the roadmap for this.

To get a little more specific, what I'd like to do is introduce a new property wrapper or macro, something to the effect of @Deferred. Rather than saving the blob to a file on disk (which could come with performance issues), what I'd rather do is use the Deferred type as a signal to not load an item into memory until it's needed or accessed. I say this because there would still be performance benefits to storing large data blobs in SQLite, even if you don't want to have them loaded into memory at all times.

Once again thank you for the suggestion, I'll make an issue to describe how I want to build this, and will try to find some time to integrate that functionality into Boutique.