ManuHub.IndexedDB
1.2.0
Prefix Reserved
dotnet add package ManuHub.IndexedDB --version 1.2.0
NuGet\Install-Package ManuHub.IndexedDB -Version 1.2.0
<PackageReference Include="ManuHub.IndexedDB" Version="1.2.0" />
<PackageVersion Include="ManuHub.IndexedDB" Version="1.2.0" />
<PackageReference Include="ManuHub.IndexedDB" />
paket add ManuHub.IndexedDB --version 1.2.0
#r "nuget: ManuHub.IndexedDB, 1.2.0"
#:package ManuHub.IndexedDB@1.2.0
#addin nuget:?package=ManuHub.IndexedDB&version=1.2.0
#tool nuget:?package=ManuHub.IndexedDB&version=1.2.0
π¦ ManuHub.IndexedDB
v1.2
A lightweight, production-ready IndexedDB wrapper for Blazor WebAssembly with EF-Core-inspired API.
π Overview
ManuHub.IndexedDB v1.2 is a robust, multi-entity IndexedDB solution for Blazor WebAssembly. It provides a clean, familiar .NET API while handling the complexities of browser storage.
β»οΈ Changelog v1.2
Major Improvements
- Full Multi-Entity Support
- Robust Migration System with version management
- Stable Data Persistence
- Smart Entity Normalization β Works with
Guid,int,stringkeys - Improved Version Conflict Handling
- Better Error Messages & Debugging
- Enhanced Service Registration with options delegate
- Stable CRUD + Batch Operations
β¨ Features
β Full CRUD + Batch operations
β Multi-entity support (multiple stores)
β EF Core-style DbContext pattern
β Robust migration & versioning system
β Guid, int, string key support
β Smart automatic Id handling
β Safe transaction management
β Production-ready stability
β Lightweight & dependency-free
π¦ Installation
dotnet add package ManuHub.IndexedDB
βοΈ Setup
1. Register in Program.cs
builder.Services.AddIndexedDb<AppDbContext>(options =>
{
options.DatabaseName = "MyAppDb";
options.Version = 5; // Increase when schema changes
// Migrations (recommended)
options.Migrations.Add(1, builder =>
{
builder.CreateStore<TodoItem>();
builder.CreateStore<User>();
});
// Add more migrations as needed
});
2. Create DbContext
public class AppDbContext : IndexedDbContext
{
public AppDbContext(IndexedDbOptions options) : base(options) { }
protected override IEnumerable<Type> GetEntityTypes()
{
return [typeof(TodoItem), typeof(User)];
}
public IndexedSet<TodoItem> Todos => Set<TodoItem>("TodoItems");
public IndexedSet<User> Users => Set<User>("Users");
}
3. Define Entities
[IndexedStore("TodoItems")]
public class TodoItem
{
[IndexedKey]
public Guid Id { get; set; } = Guid.NewGuid();
public string Title { get; set; } = string.Empty;
public bool IsDone { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
π§ͺ Usage
Basic Operations
// Add
await db.Todos.AddAsync(new TodoItem { Title = "Learn ManuHub.IndexedDB" });
// Get All
var allTodos = await db.Todos.GetAllAsync();
// Query
var completed = await db.Todos.Query()
.WhereEquals("IsDone", true)
.ToListAsync();
// Update & Delete
await db.Todos.UpdateAsync(todo);
await db.Todos.DeleteAsync(todo.Id);
Batch Operations
await db.Todos.AddRangeAsync(items);
await db.Todos.UpdateRangeAsync(updatedItems);
await db.Todos.DeleteRangeAsync(idsToDelete);
π Migrations (v1.2 Feature)
Basic Migration Example
builder.Services.AddIndexedDb<AppDbContext>(options =>
{
options.DatabaseName = "MyAppDb";
options.Version = 3; // Current version
options.Migrations.Add(1, builder =>
{
builder.CreateStore<TodoItem>();
builder.CreateStore<User>();
});
options.Migrations.Add(2, builder =>
{
builder.CreateStore<Project>();
});
options.Migrations.Add(3, builder =>
{
builder.CreateStore<TodoItem>(); // Re-apply if needed
// Optional: Data transformation
// builder.TransformData<TodoItem>(todo => { ... });
});
});
Advanced Migration with Data Transformation
options.Migrations.Add(4, builder =>
{
builder.CreateStore<Order>();
// Transform existing data during migration
builder.TransformData<TodoItem>(todo =>
{
todo.UpdatedAt = DateTime.UtcNow;
todo.Version = 2;
return todo;
});
});
π Architecture
Blazor App
β
IndexedDbContext
β
IndexedSet<T> / IndexedQuery<T>
β
Smart JS Interop Layer (Multi-entity safe)
β
IndexedDB Browser API
βοΈ Key Improvements in v1.2
- Removed hardcoded
normalizeEntity(Todo-only) - Smart generic entity normalization
- Reliable database versioning (no more data loss on refresh)
- Better fallback for
Id/Guidkeys - Stable migration system
- Improved error handling & logging
π License
MIT License
π€ Contributing
Pull requests, bug reports, and feature suggestions are welcome.
β Status
| Property | Value |
|---|---|
| Version | 1.2.0 |
| Stability | Production Ready |
| Target | Blazor WebAssembly |
| Scope | Client-side IndexedDB ORM |
Made with β€οΈ for the Blazor community
| 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 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.8)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.27)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.