lucky_record icon indicating copy to clipboard operation
lucky_record copied to clipboard

Add Queryable#empty?

Open edwardloveall opened this issue 6 years ago • 1 comments

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 avatar Jan 20 '19 03:01 edwardloveall

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.

edwardloveall avatar Feb 02 '19 22:02 edwardloveall