Skip to content
This repository has been archived by the owner on Oct 28, 2019. It is now read-only.

Add Queryable#empty? #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Queryable#empty? #310

wants to merge 1 commit into from

Conversation

edwardloveall
Copy link
Member

I find that I'm looking for this functionality when I want to show
something on a page based on the presence of a record. For example, an
empty-state UI that shows "No posts yet" as opposed to listing out all
posts. This could check a PostQuery.new.empty? to determine whether to
loop through posts or show a sad face.

I also thought about checking for first? but that returns a record if
it's present. That could be worked around with !...nil? but at that
point size.zero? seemed like a pretty solid choice. Also, maybe it's
faster?

I find that I'm looking for this functionality when I want to show
something on a page based on the presence of a record. For example, an
empty-state UI that shows "No posts yet" as opposed to listing out all
posts. This could check a PostQuery.new.empty? to determine whether to
loop through posts or show a sad face.

I also thought about checking for `first?` but that returns a record if
it's present. That could be worked around with `!...nil?` but at that
point `size.zero?` seemed like a pretty solid choice. Also, maybe it's
faster?
@edwardloveall
Copy link
Member Author

Hey me! We've moved and renamed LuckyRecord to Avram. We decided to move it instead of using GitHub's rename option so that current code that relies on lucky_record would continue to work and a project must opt-in to the new shard. However, a big bummer is we can't move PRs.

If you are still interested in this change, would you be able to rebase onto Avram? If not don't worry about it. We can eventually rebase it for you. Thanks 😄! Let us know if you have any questions.

P.S. This is pretty silly of me to leave a comment for myself, but hey, it only seems fair.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant