Tavenem.Blazor.IndexedDB
6.0.6
Prefix Reserved
dotnet add package Tavenem.Blazor.IndexedDB --version 6.0.6
NuGet\Install-Package Tavenem.Blazor.IndexedDB -Version 6.0.6
<PackageReference Include="Tavenem.Blazor.IndexedDB" Version="6.0.6" />
<PackageVersion Include="Tavenem.Blazor.IndexedDB" Version="6.0.6" />
<PackageReference Include="Tavenem.Blazor.IndexedDB" />
paket add Tavenem.Blazor.IndexedDB --version 6.0.6
#r "nuget: Tavenem.Blazor.IndexedDB, 6.0.6"
#:package Tavenem.Blazor.IndexedDB@6.0.6
#addin nuget:?package=Tavenem.Blazor.IndexedDB&version=6.0.6
#tool nuget:?package=Tavenem.Blazor.IndexedDB&version=6.0.6
Tavenem.Blazor.IndexedDB
Tavenem.Blazor.IndexedDB is a Razor class library (RCL) containing a Razor component. It grants managed access to the IndexedDB API.
It uses the idb javascript library by Jake Archibald, and implements the IDataStore
interface from the Tavenem DataStore library.
Installation
Tavenem.Blazor.IndexedDB is available as a NuGet package.
Use
Register the
IndexedDbService
with dependency injection.builder.Services.AddIndexedDbService();
Register one or more
IndexedDb
instances with dependency injection.// simple builder.Services.AddIndexedDb("myDatabaseName"); // all options builder.Services.AddIndexedDb( databaseName: "myDatabaseName", // the database name objectStores: ["valueStore"], // the names of value stores version: 2, // the version number of the current database schema jsonSerializerOptions: options); // a JsonSerializerOptions instance
Note that use of dependency injection for database instances is optional. They can also be initialized on demand with their public constructor, which requires an instance of
IndexedDbService
.Inject an
IndexedDb
instance in a component.[Inject(Key = "myDatabaseName")] private IndexedDb MyDatabase { get; set; } = default!;
Note that the
@inject
directive does not currently support keyed services.Retrieve an
IndexedDbStore
instance by name.var store = MyDatabase["valueStore"];
Call the
StoreItemAsync<T>
,GetItemAsync<T>
, andRemoveItemAsync<T>
methods on anIndexedDbStore
to work with strongly-typed data items.class Item : IIdItem { public string Id { get; set; } public string? Value { get; set; } } var item = new Item { Id = "1", Value = "Hello, World!", }; await store.StoreItemAsync(item); item.Value = "Goodbye!"; await store.StoreItemAsync(item); var fetchedItem = await store.GetItemAsync<Item>(item.Id); // fetchedItem is an Item instance: item.Value == "Goodbye!" await store.RemoveItemAsync(item); fetchedItem = await store.GetItemAsync<Item>(item.Id); // fetchedItem is null
Call the
Query<T>
method to obtain anIDataStoreQueryable<T>
.IDataStoreQueryable<T>
is similar toIQueryable<T>
, and can be used to make queries against the data source.await foreach (var item in store.Query<Item>().AsAsyncEnumerable()) { Console.WriteLine(item.Value); } var helloCount = await store .Query<Item>() .Select(x => x.Value != null && x.Value.Contains("Hello")) .CountAsync();
Call the
ClearAsync
,CountAsync
, andGetAllAsync<T>
methods to work with the full object store.await store.StoreItemAsync(item); var count = await store.CountAsync(); // count = 1 var items = await store.GetAllAsync<Item>(); // items is an array of Items with Length 1 await store.ClearAsync(); count = await store.CountAsync(); // count = 0
Call the
DeleteDatabaseAsync
method on theIndexedDb
instance to remove the entire database.await MyDatabase.DeleteDatabaseAsync(); // the database has been removed (or will be, after all connections are closed)
Roadmap
New versions of Tavenem.IndexedDb should be expected whenever the API surface of the Tavenem DataStore library receives an update.
Other updates to resolve bugs or add new features may occur at any time.
Contributing
Contributions are always welcome. Please carefully read the contributing document to learn more before submitting issues or pull requests.
Code of conduct
Please read the code of conduct before engaging with our community, including but not limited to submitting or replying to an issue or pull request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.17)
- Tavenem.DataStore (>= 2.0.4)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.6)
- Tavenem.DataStore (>= 2.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
6.0.6 | 207 | 6/24/2025 |
5.1.4 | 977 | 1/24/2025 |
5.0.2 | 415 | 12/27/2024 |
4.2.4 | 183 | 12/17/2024 |
4.1.4 | 257 | 11/21/2024 |
4.0.2 | 1,334 | 6/30/2024 |
3.0.2 | 819 | 3/20/2024 |
2.3.4 | 177 | 3/5/2024 |
2.2.4 | 168 | 2/12/2024 |
2.1.2 | 223 | 11/29/2023 |
2.0.3-preview1 | 227 | 12/4/2022 |
2.0.1 | 156 | 11/27/2023 |
1.0.0 | 688 | 12/8/2021 |