vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.32k stars 172 forks source link

Adding support for decoding optional models #642

Closed MatsMoll closed 4 years ago

MatsMoll commented 5 years ago

This could be useful when having a database structure that uses subclassing.

Think of the scenario where only the id of the superclass is know, but you need the extra information form the subclasses that also contain the same id.

By using optional decoding, you would be able to left join the different types on the ids and from there derive what type it is.

The alternative would to do a .find(...) on the different models, but this would lead to more requests and possibly a lower performance.