[Question] Hook/intercep before deserializing json document #2221
-
Hi all, Is there a way in MartenDB to intercept a JSON document before it gets converted to CLR object? (I'm currently on Marten V3). The reason I'm interested in this type of hook/callback is to apply on-the-fly migrations/transformations to the JSON. I know marten supports JSON transformations using the patch API or using javascript transformations, but these are executed on the database side and it doesn't scale very well and, somehow, limited. Running transformations on the .NET side would allow much more powerful and complex transformations to be performed. Please let me know what options do I have? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
https://martendb.io/diagnostics.html#listening-for-document-store-events - Check https://martendb.io/v3/documentation/documents/diagnostics - v3 docs pertaining to Edit: I don't think you can modify the loaded docs. This will need to be an enhancement to deal with. |
Beta Was this translation helpful? Give feedback.
-
Thanks @mysticmind . Are there any plans for adding such hook in IDocumentSessionListener ? Thanks, |
Beta Was this translation helpful? Give feedback.
-
@sszakal we are happy to take a PR. Note that 3.x is in maintenance mode so we are not adding any new features/enhancements. This feature will need to be in the latest 5.x. @jeremydmiller Could you please provide some pointers for Stefan to take look at this? |
Beta Was this translation helpful? Give feedback.
-
In version 5.9.0, we added Upcaster functionality that allows transforming events' JSON payloads on the fly. Read more in https://martendb.io/events/versioning.html#upcasting-advanced-payload-transformations 🙂 |
Beta Was this translation helpful? Give feedback.
In version 5.9.0, we added Upcaster functionality that allows transforming events' JSON payloads on the fly. Read more in https://martendb.io/events/versioning.html#upcasting-advanced-payload-transformations 🙂