Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for on-the-fly document upgrades #2489

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

JKamsker
Copy link
Collaborator

@JKamsker JKamsker commented Jun 1, 2024

This change would allow me to improve my library (https://github.com/JKamsker/LiteDb.Migration) significantly. The documents would then only be upgrades on load and not all at once.

@JKamsker
Copy link
Collaborator Author

JKamsker commented Jun 5, 2024

This also addresses #2430

@JKamsker JKamsker requested a review from pictos June 5, 2024 20:05
Copy link
Member

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into the issue for more context, I think is better to @mbdavid to take a look on this and see if he wants to perform this change, or if using the protected methods are enough

LiteDB/Client/Database/LiteDatabase.cs Outdated Show resolved Hide resolved
LiteDB/Engine/EngineSettings.cs Outdated Show resolved Hide resolved
LiteDB/Engine/EngineState.cs Outdated Show resolved Hide resolved
@JKamsker
Copy link
Collaborator Author

JKamsker commented Jun 6, 2024

@pictos Thanks for the review, how did that slip through, that its a breaking change 😅
Reverted the breaking changes and updated your requested changes.

So in my latest commit i added a deserialization hook.

Upsides:

  • It is easier to add your own hook into that, because you only need a reference to the mapper
  • Should be easier on the cpu because it only transforms those documents, which are actually needed.

Downsides:

  • Queries may not run as expected, because there could be a transform between the query engine and the actual transform. But if that is a concern, the user should just use the ReadTransform in the engine settings.

@JKamsker JKamsker requested a review from pictos June 6, 2024 22:58
Copy link
Member

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm away from my pc, so I can't test it right now

LiteDB/LiteDB.csproj Outdated Show resolved Hide resolved
JKamsker and others added 2 commits June 7, 2024 01:36
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
@JKamsker
Copy link
Collaborator Author

Some tests failed before which are succeding (not the tests i touched)...sooo...

@pictos Can we merge? 😅

@JKamsker JKamsker requested a review from pictos June 10, 2024 21:42
@@ -78,6 +96,15 @@ public T Deserialize<T>(BsonValue value)
/// </summary>
public object Deserialize(Type type, BsonValue value)
{
if (OnDeserialization is not null)
{
var result = OnDeserialization(this, type, value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consicise with all code base, let's use "this." for instance methods, properties and public fields (only private _ name has no "this.")

@mbdavid mbdavid merged commit 8406508 into litedb-org:master Jul 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants