Author : MD TAREQ HASSAN | Updated : 2021/03/01
IndexedDB
- IndexedDB is a large-scale, NoSQL storage system (NoSQL database of JSON objects)
- It lets you store just about anything in the user’s browser. In addition to the usual search, get, and put actions, IndexedDB also supports transactions
- IndexedDB is a way to persistently store data inside a user’s browser
- IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs
- IndexedDB is useful for applications that store a large amount of data (for example, a catalog of DVDs in a lending library) and applications that don’t need persistent internet connectivity to work (for example, mail clients, to-do lists, and notepads)
- The Indexed Database API is a JavaScript application programming interface provided by web browsers. It is a standard maintained by the World Wide Web Consortium
- An alternative to the Web storage standard ( Web storage -> session storage, localStorage)
- IndexedDB can provide more storage capacity than Web storage
- Links
Usage in BlazorWebassembly
SQLite
SqlLite needs file system to save data to. Typically web browser don’t let JavaScript directly access the file system and Blazor wasm is no different. So, as of now SQLite can not be used in Blazor WebAssembly.
Blazor on WebAssembly runs in the same security context as JavaScript, and is therefore subject to the same limitations as Javascript when it comes to accessing resources outside of its process. You will need an API.
Workaround for SQLite using wrapper (experimental, not recommended to use in production): https://vkbansal.me/blog/sqlite-in-browser-using-webassembly-wasm/ EF Core usage in Blazor WebAssembly: https://github.com/dotnet/efcore/issues/18908#issuecomment-600718924
JSON file based custom solution
- This is just my own idea
- Hierarchical JSON file based store
Example
NCDBLite
- table_001
- row_id_001.json
- row_id_002.json
- table_002
-
-