Closed thanhnguyen2187 closed 8 months ago
One related article: https://www.powersync.com/blog/sqlite-persistence-on-the-web
Right now, I’d recommend wa-sqlite’s IDBBatchAtomicVFS for most use cases - it has good performance, supports concurrent reads, has wide browser support, and is a fairly mature implementation.
Got stuck with a strange error:
caught (in promise) TypeError: Cannot read properties of null (reading 'fileSize')
at IDBBatchAtomicVFS.xFileSize (IDBBatchAtomicVFS.js:383:47)
at Ac (wa-sqlite.mjs?url:70:293)
at wa-sqlite.wasm:0x3d580
at wa-sqlite.wasm:0x52645
at wa-sqlite.wasm:0x14eb4
at wa-sqlite.wasm:0x3e0cd
at wa-sqlite.wasm:0x37533
at wa-sqlite.wasm:0xe90e
at wa-sqlite.wasm:0x3d1d2
at wa-sqlite.wasm:0x27646
Task list:
More on database design, it seems... obvious to have these tables:
snippets
: which stores the snippetsfolders
: which stores the snippets' folderstags
: which stores the snippets' tagssnippet__tag
: which links between snippets and tagsThe question is for tags
and snippet__tag
: do we need something like that?
In the end, we settled with snippet_tags
, which store snippet
's ID and the tag's text. It seems to be good enough, since making it too normalized can be complex on adding new tag completely.
Another note for SQLite migration: we can use PRAGMA user_version
.
PRAGMA user_version;
PRAGMA user_version = 1;
https://stackoverflow.com/questions/989558/best-practices-for-in-app-database-migration-for-sqlite
Everything seems to work well enough for now. Should test it thoroughly before merging:
Snippet cloning doesn't work. Should note this for later resolving.
To solve a smaller part of #26 that revolves around using SQLite in browser.