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

[SUGGESTION] Save/Load Hooks #2430

Open
JKamsker opened this issue Feb 20, 2024 · 2 comments
Open

[SUGGESTION] Save/Load Hooks #2430

JKamsker opened this issue Feb 20, 2024 · 2 comments

Comments

@JKamsker
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
In my library (LiteDB.Migration) i support "Implicit migrations" which automatically migrates a document at load time and adds a __version field on save (Here)

Currently it is very hacky and not really stable (The order of mapping registrations must be correct.)

Describe the solution you'd like
One of two things:

  • Implement and accept IBsonMapper: This way, i could use a wrapper which only holds my "Versionable" registrations
  • Load/Save hooks that get called when a document is loaded/saved (must be r/w)

Describe alternatives you've considered
See https://github.com/JKamsker/LiteDB.Migration/blob/master/LiteDb.Migration/MigrationRegistry.cs#L297

@mbdavid
Copy link
Collaborator

mbdavid commented Feb 20, 2024

Olá @JKamsker,

How cool is your lib for versioning. I always thought about using versioning using fixed code structures and that's why from the beginning I have the USER_VERSION field to track the versions.
Regarding your lib, the BsonMapper class I created thinking about being overwritten with changes to these rules (that's why there are some protected methods there).
I will check if there is any impact on creating this interface and adjust it soon.

@JKamsker
Copy link
Collaborator Author

Uh, Thanks 😅 I am trying to create something nice 😀
Didn't know about USER_VERSION but i could incorperate it into my project 👍
Although i am not quite sure, because the lib works on a document/collection level.

Thanks for considering to alter your BsonMapper for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants