-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support #find_by, #find_by!, #where, #order, and #limit #56
Conversation
.where, .order, and .limit can be chained together in any order
Updated this today with clearer variable names |
Hey @chrisfrank, will try to get to this soon—sorry, the beginning of a new year is typically busy :) |
No worries :) |
Hello, thank you to both for the gem and this PR. I was wondering if you will close this PR or integrate it :) |
Thanks for resurfacing this, @jmgarnier. I defer to @sirupsen, but when I look at this now, I'm seeing a major change to a stable gem, and one that duplicates functionality already available via the I'd propose scaling this back to just |
@jmgarnier, I'd love to hear more about which features from this PR would be helpful to you. Is it the method-chaining style? Or that you could filter records via plain Ruby hashes instead of using Airtable formulas? Something else? I don't yet see a way to support chaining that addresses the worries I expressed yesterday, but I actually think we could support filtering with hashes. @sirupsen, what if we adjusted the Also, @jmgarnier, I'm realizing I never acknowledged your kind offer to help work on this :) Thank you very much for being willing to pitch in. Once we figure out how to proceed, I'd be happy to review a PR! |
This got snoozed a pretty long time unfortunately. Anyone feel strongly about reviving it, or shall we close it? |
👍 Feel free to close |
This PR closes #19 and makes the following behavior possible:
I still need to update the README and changelog, but wanted to make sure this approach looks okay to you, @sirupsen. I'm happy with it so far, but have some questions:
#where
accept raw Airtable formula components, in addition to the conditions hash it currently accepts? LikeTea.where("Type => "Green").where("{Price} < 30")
?#where
,#order
, and#limit
all return an instance of Airrecord::Relation, an Enumerable that only callsTable#records
after you try do something with it, likeeach
,map
,to_a
, etc. In 2.0, should thehas_many
API also return a Relation instead of an Array, so you could callTea.find(id).brews.where("Temperature" => 90)
?