simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.52k stars 358 forks source link

Add toJson() for result class #3060

Open andim27 opened 2 months ago

andim27 commented 2 months ago

Pleas add if it is possible to generated classes(*.g.dart) .toJson() method class MyTableItemsResult { fields ... toJson(){..return all fields in json format} }

simolus3 commented 2 months ago

For what do you need json serialization here? You can probably get close to this already by enabling the raw_result_set_data builder option. Then you can use QueryRow.data to get access to the underlying fields.

If you need more complex serialization features, I suggest writing your own data class and then using custom result classes.