mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.36k stars 1.22k forks source link

[SUGGESTION] Save/Load Hooks #2430

Open JKamsker opened 4 months ago

JKamsker commented 4 months ago

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:

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

mbdavid commented 4 months ago

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 commented 4 months ago

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!