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

Support selection of columns #609

Closed grosch closed 4 years ago

grosch commented 5 years ago

Using fluent results in all columns from the table being returned, which can be quite excessive if the table has many columns and many rows, and so I always end up falling back to the direct conn.select() type calls. Can you please add something to the fluent queries so that we can include the list of columns that we want returned?

calebkleveter commented 5 years ago

This is the plan for Fluent 4. Because the way Fluent is currently built, we probably wouldn't be able to make the change without breaking the public API.

tanner0101 commented 5 years ago

Yeah, as @calebkleveter said this is not really possible given Fluent 3's design. Models are Codable meaning that all of the data must be there to initialize the model, even if you don't need it.

Fluent 4's model design will allow for initialization with partial or even empty result set, allowing us to add API for selecting only a subset of fields 👍

tanner0101 commented 4 years ago

This is available in Fluent 4.