Skip to content

Releases: magiccodingman/Magic.IndexedDb

Magic IndexDB v1.0.12 Release Notes

10 Mar 23:16
Compare
Choose a tag to compare

πŸš€ Hotfix/Patch

πŸ“’ NuGet Release: Magic.IndexedDb v1.0.12

This hotfix/patch resolves issues that were created from and prior to version 1.0.11.

πŸ”¨ Bug Fixes

βœ” Resolved Skip complex query issues.
βœ” Fixed null value serialization issues.
βœ” Corrected error which fixes/allows developers to compare to nulls like, (x.DateOfBirth == null) or (x.DateOfBirth != null). Note for reference the Equals and !Equals are supported operations as well.
βœ” Fixed multiple edge case Not Equals != scenarios.

Magic IndexDB v1.0.11 Release Notes

10 Mar 16:45
9664c6a
Compare
Choose a tag to compare

πŸš€ Performance Overhaul, Streamed Queries, and Future-Proofed Execution

πŸ“’ NuGet Release: Magic.IndexedDb v1.0.12

  • Use the v1.0.12 hotfix/patch

This update removes major bottlenecks, eliminates redundant serialization, drastically improves query performance, and introduces new future-proofed execution methods.


πŸ”₯ Key Enhancements in v1.0.11

1️⃣ Eliminated Blazor Interop Overhead – No More Double Serialization

  • Removed Blazor's built-in interop handling, replacing it with a custom system using magicDbMethods.js.
  • Eliminates redundant JSON serialization & deserialization, vastly improving performance.
  • πŸš€ Bandwidth Increase:
    • 4.4x on Blazor WASM.
    • 2,250x on Blazor Server (SignalR).

2️⃣ Streamed Async Communication – No More Transfer Limits

  • Moved all data transfers to streamed async communication, bypassing Blazor’s built-in size restrictions:
    • βœ… No more 16MB limit on Blazor WASM.
    • βœ… No more 32KB SignalR limit on Blazor Server.
    • βœ… Uncapped data transfer, enabling handling of larger datasets.
  • πŸš€ Performance gain outweighs the minor latency increase due to eliminating double serialization.

3️⃣ New [MagicName] Attribute – Rename Columns Without Indexing

  • New [MagicName("NewPropertyName")] attribute allows renaming columns in IndexedDB without forcing them to be an index, unique key, or primary key.
  • Example Usage:
    public class Person
    {
        [MagicPrimaryKey("id")] 
        public int Id { get; set; }
        
        [MagicName("FullName")]
        public string Name { get; set; }
    }
    • Results: The Name property is stored in IndexedDB as "FullName" but behaves normally in C#.
    • Benefit: Greater flexibility in defining storage structure without unnecessary indexing.

4️⃣ Major Boost to where Query Performance

  • Now utilizes IndexedDB cursors instead of inefficient in-memory filtering.
  • πŸš€ Drastic reduction in memory usage and execution time.
Feature Old Version New Version Improved?
Dynamically handles conditions (Equal, GreaterThan, LessThan, etc.) βœ… Yes βœ… Yes ❌ No
Supports OR conditions (jsonQueries with multiple conditions) βœ… Yes βœ… Yes (parallel execution) βœ… Improved
Supports sorting (orderBy, orderByDescending) βœ… Yes βœ… Yes ❌ No
Supports pagination (skip, take, takeLast) βœ… Yes βœ… Yes ❌ No
Supports indexed queries when possible ❌ No (forced in-memory filtering via .and()) βœ… Yes (checks for indexed properties first) βœ… Improved
Supports cursor-based iteration for large datasets ❌ No (always loads everything into memory) βœ… Yes (avoids memory bloat with .each()) βœ… Improved
Executes OR queries in parallel ❌ No (sequential execution) βœ… Yes (Promise.all() for speed) βœ… Improved

This also does mean that you can now query non indexed columns with the LINQ Where clause as long as it doesn't have the "MagicNotMapped" attribute!


πŸ”„ Future-Proofed Query Execution – Execute() Is Now Obsolete

  • Deprecated Execute() and introduced new optimized methods:
Method Description
ToListAsync() Executes the MagicQuery and returns results as List<T>.
AsAsyncEnumerable() Executes the MagicQuery and returns results as IAsyncEnumerable<T>.
{NOT YET SUPPORTED} ToList() (FUTURE FEATURE) Executes the MagicQuery and returns results as List<T>.
{NOT YET SUPPORTED} AsEnumerable() (FUTURE FEATURE) Executes the MagicQuery and returns results as IEnumerable<T>.
  • ToListAsync() and AsAsyncEnumerable() are now the recommended execution methods for better optimization and long-term stability.
  • Planned Features: Synchronous ToList() and AsEnumerable() methods will be introduced in a future update.
  • Important note about AsAsyncEnumerable. The current AsAsyncEnumerable emulates properly providing "IAsyncEnumerable" but this feature has not yet been fully implemented. But it is a future proofed version that is safe to utilize even if full functionality isn't there yet. As it's currently just returning an IEnumerable as IAsyncEnumerable.

Complex Query Support – LINQ-Style Queries for IndexedDB

IndexedDB now supports advanced LINQ-style querying with full filtering, ordering, and pagination capabilities. Nested OR conditions is what this update brings to life. You can now build complex nested where statements in full!

Example Query:

await manager.Where<Person>(
        x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
        || x.Name.StartsWith("l", StringComparison.OrdinalIgnoreCase)
        || x.Name.StartsWith("j", StringComparison.OrdinalIgnoreCase) && x._Age > 35
    ).OrderBy(x => x._Id).Skip(1).ToListAsync();

People In IndexedDB!

ID Name Age Not Mapped Access
17 Zack 45 CanRead
18 Luna 35 CanRead, CanWrite
19 Jerry 35 CanRead, CanWrite, CanCreate
20 Jon 37 CanRead
21 Jack 37 CanRead, CanWrite
22 Cathy 22 CanRead, CanWrite
23 Bob 69 CanRead
24 Alex 80 None

Returned Results:

Name: Cathy - Age: 22
Name: Luna - Age: 35
Name: Jon - Age: 37
Name: Jack - Age: 37

πŸ”Ž Query Breakdown:

  1. βœ… Filters names starting with "C", "L", or "J" (if age > 35).
  2. βœ… Orders by ID in ascending order.
  3. βœ… Skips the first result (correct pagination support).
  4. βœ… Uses IndexedDB cursors to optimize execution.

πŸ”¨ Other Fixes & Enhancements

βœ” Implemented cursor-based querying for non-indexed fields.
βœ” Fixed complex query translation issues.
βœ” Corrected camel-case property handling in attributed Magic Tables.
βœ” Refactored execution commands for better usability and performance.


πŸ”§ Upcoming Refactor – Simplifying MagicDbFactory for Seamless Database Access

A major refactor is planned for how users interact with the MagicDbFactory manager, aiming to eliminate all manual configuration and streamline database initialization.

πŸš€ What’s Changing?

  • No more user input required – databases will be automatically initialized and managed.
  • Simplified API usage – making Magic.IndexedDb easier to work with across multiple databases.

⚠ Known Issues & Current Limitations:

  • There are existing bugs and inconsistencies when accessing multiple databases under certain scenarios.
  • These issues have always existed but will be fully addressed in the upcoming refactor.

πŸ”§ Priority Fix: This refactor is a top priority and will be implemented in an upcoming update.


πŸ“ Final Thoughts

This release drastically enhances IndexedDB performance in Blazor, eliminates wasteful serialization, and introduces optimized, future-proofed execution methods.

πŸ“’ NuGet Release: Magic.IndexedDb v1.0.12

Magic IndexDB v1.0.10 Release Notes

09 Mar 17:40
Compare
Choose a tag to compare

Special Thanks πŸ™Œ

A huge shoutout to @yueyinqiu for major contributions and support in this update! Your help has been invaluable in refining and optimizing the project.


πŸ”₯ Major Enhancements

βœ… New Unit Test Library πŸ§ͺ

  • A dedicated unit testing library has been introduced to rigorously validate all functionality.
  • This significantly improved testing coverage, allowing us to catch and resolve numerous edge cases and issues.

⚑ Complete Serialization Overhaul πŸš€

  • Massive rework of the serialization process, improving performance, reliability, and capability to a whole new level.
  • Introduced a fully customized serializer and deserializer, removing significant runtime reflections and unnecessary processing.
  • New caching techniques drastically improve performance:
    • Discovery and caching of information now happens primarily at startup, ensuring minimal runtime overhead.
    • Information is cached once per encounter and reused efficiently.
  • This refactor opens doors for future enhancementsβ€”share your ideas in the GitHub Discussions.

πŸ› Bug Fixes

This release isn’t just about performance! Multiple critical bug fixes have been addressed:

βœ”οΈ Fixed retrieving complex types.
βœ”οΈ Fixed usage of variables in Where predicates.
βœ”οΈ Fixed Array.Contains() behavior.
βœ”οΈ Fixed ensuring unique results return correctly.
βœ”οΈ Fixed issues with Contains clauses.
βœ”οΈ Fixed retrieving ID of newly added records.
βœ”οΈ Fixed numerous issues related to enums.
βœ”οΈ Fixed Ignore attributes now properly respected.
βœ”οΈ Fixed handling of multiple attributes in nested operations.

🚨 These are just some of the fixesβ€”many more improvements have been made! 🚨


⚠️ Breaking Changes & Deprecations

πŸ”‘ Encryption Attribute Removed

  • The encryption attribute has been removed, as we are planning a much better way to reintroduce encryption in the future.
  • It is now marked as obsolete and no longer functions, but remains in place to allow projects time to migrate.
  • Full removal will occur in future updates.

πŸ’‘ Join the Discussion

This update brings major improvements, but there’s always room for more! If you have ideas for enhancements or additional features, share your thoughts in the GitHub Discussions.

πŸ”₯ Thank you to everyone who contributed to this release! Your feedback, support, and contributions are what make this project great.

Nuget Release:
https://www.nuget.org/packages/Magic.IndexedDb/1.0.10