Serialization/Deserialization
Hi :), I've been using this framework for developing an API REST. The framework is simple and works fine, but I think that the serialization/deserialization process could be improved.
The process of serialization in a Lucid model is determined by its serializer. But, ¿what about the inverse process? You can deserialize a JSON object as described here:
https://github.com/adonisjs/adonis-lucid/issues/202
But it doesn't seem to be a Deserialization API. You can write code that just works, but I am not able to code as clean as I'd like. Maybe the serializer should be in the middle of the deserialization process.
As an example, if we supose that we want a CamelCaseSerializer, maybe we could use the one that @thetutlage coded in https://github.com/adonisjs/adonis-framework/issues/699#issuecomment-342072671, but we could have a problem at deserializing a serialized model, because Model.newUp(json) does not use the serializer. Even if Model.newUp(json) would call the serializer, the serializer does not contains a definition of the inverse transformation, so now there's no point at calling the serializer.
In this scenario, ¿how could I write a clean code without writing a framework? Maybe the serializer could have an optional function toModel(model, json) that receives the target model (as a class/prototype) and the serialized JSON).
¿What do you think about this?