Chainable Query Builder with select #3341
Replies: 2 comments 1 reply
|
Hey Mike — people = model("Person")
.select("firstName,lastName,email")
.where("id", "1234")
.get();
If that 500s or you get |
|
Thanks Mike — that stack is the 4.0.5 gap, not a bad model. On 4.0.5, either start with people = model("Person")
.where("id", "1234")
.select("firstName,lastName,email")
.get();or the finder form: people = model("Person").findAll(select="firstName,lastName,email", where="id = 1234");Leading with |
Uh oh!
There was an error while loading. Please reload this page.
I started playing around with the chainable query builder (https://guides.wheels.dev/v4-0-0/basics/query-builder-and-scopes/), and it seems to be working well. Might like this better than findall() at some point. However, I find myself wanting to still limit the fields down to just what is needed. Select doesn't seem to be chainable?
Something like this
model("person")
.select("firstname,lastname,email")
.where("id","1234")
.get();
I see some Rails has some docs on their implementation.
https://guides.rubyonrails.org/active_record_querying.html#selecting-specific-fields
All reactions