TG.Blazor.IndexedDB
0.9.0-beta
See the version list below for details.
dotnet add package TG.Blazor.IndexedDB --version 0.9.0-beta
NuGet\Install-Package TG.Blazor.IndexedDB -Version 0.9.0-beta
<PackageReference Include="TG.Blazor.IndexedDB" Version="0.9.0-beta" />
paket add TG.Blazor.IndexedDB --version 0.9.0-beta
#r "nuget: TG.Blazor.IndexedDB, 0.9.0-beta"
// Install TG.Blazor.IndexedDB as a Cake Addin #addin nuget:?package=TG.Blazor.IndexedDB&version=0.9.0-beta&prerelease // Install TG.Blazor.IndexedDB as a Cake Tool #tool nuget:?package=TG.Blazor.IndexedDB&version=0.9.0-beta&prerelease
Tg.Blazor.IndexedDB
This is Blazor library for accessing IndexedDB and uses Jake Archibald's idb library for handling access to IndexedDB on the JavaScript side.
This version currently provides the following functionality.
- Open and upgrade an instance of IndexedDB, creating stores
- Add and update a record to/in a given store
- Delete a record from a store
- Retrieve all records from a given store
- Retrieve a record/or records from a store by index and value if the index exists
It does not, at the moment, support aggregate keys, searches using a range and some of the more obscure features of IndexedDB.
Using the library
- create a new instance of DbStore
- add one or more store definitions
- Inject the created instance of IndexedDbManger into the component or page where you want to use it
The library provides a service extension to create a singleton instance of the DbStore.
Within the client application's startup.cs file, add the following to the ConfigureServices
function.
services.AddIndexedDB(dbStore =>
{
dbStore.DbName = "TheFactory"; //example name
dbStore.Version = 1;
dbStore.Stores.Add(new StoreSchema
{
Name = "Employees",
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec{Name="firstName", KeyPath = "firstName", Auto=false},
new IndexSpec{Name="lastName", KeyPath = "lastName", Auto=false}
}
});
dbStore.Stores.Add(new StoreSchema
{
Name = "Outbox",
PrimaryKey = new IndexSpec { Auto = true }
}
);
});
A breakdown of what this does
Using IndexedDBManager
For the following examples we are going to assume that we have Person class which is defined as follows:
public class Person
{
public long? Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
And the data store name is "Employees"
Accessing IndexedDBManager
To use IndexedDB in a component or page first inject the IndexedDbManager instance.
@inject IndexedDBManager DbManager
Setting up notifications
IndexedDBManager exposes ActionCompleted
event that is raised when an action is completed.
If you want to receive notifications in the ```OnInit()`` function subscribe to the event.
The function that handles the event should have the following signature:
private void OnIndexedDbNotification(object sender, IndexedDBNotificationArgs args)
{
Message = args.Message;
}
It is recommended that your page or component should also implement IDisposable to unsubscribe from the event.
Adding a record to an IndexedDb store
Assuming we have a new instance of our sample Person
class, to add to the "Employees" store doing the following:
var newRecord = new StoreRecord<Person>
{
Storename ="Employees",
Data = NewPerson
};
await DbManager.AddRecord(newRecord);
Getting all records from a store
var results = await DbManager.GetRecords<Person>("Employees");
getting a record using the index
B
Updating a record
Deleting a record
Query by index key
Change Logs
2019-06-25
- Upgraded to Blazor 3.0.0 preview 6.
2019-04-21
- Upgraded to Blazor 0.9.0-preview3-19154-02 (thanks Behnam Emamian).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Components.Browser (>= 3.0.0-preview6.19307.2)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on TG.Blazor.IndexedDB:
Package | Downloads |
---|---|
Reshiru.Blazor.IndexedDB.Framework
A Blazor framework for interacting with IndexedDB |
|
IndexedDB.Blazor
A Blazor library for accessing IndexedDB |
|
Johnjalani.Blazor.IndexedDB.WebAssembly
A Blazor web assembly for interacting with IndexedDB |
|
IndexedDB.Blazor.Net8
A Blazor library for accessing IndexedDB |
|
IndexedDB.Blazor.sisn
A Blazor library for accessing IndexedDB |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on TG.Blazor.IndexedDB:
Repository | Stars |
---|---|
Tewr/BlazorWorker
Library for creating DotNet Web Worker threads/multithreading in Client side Blazor
|
|
KristofferStrube/Blazor.FileSystemAccess
A Blazor wrapper for the File System Access browser API.
|
Version | Downloads | Last updated |
---|---|---|
1.5.0-preview | 184,865 | 1/8/2020 |
1.2.1-preview | 1,200 | 10/7/2019 |
1.2.0-preview | 325 | 9/17/2019 |
1.1.0-preview | 335 | 8/21/2019 |
1.0.0-preview | 311 | 8/15/2019 |
0.9.0-beta | 29,481 | 6/29/2019 |
0.6.0-beta | 513 | 11/17/2018 |
Updated to Blazor 3.0.0-preview6