{"repo":"rzane/baby_squeel","free":true,"listed":false,"github":"https://github.com/rzane/baby_squeel","clone":"git clone https://github.com/rzane/baby_squeel.git","description":":pig: An expressive query DSL for Active Record","language":"Ruby","stars":507,"topics":["squeel","arel","query","dsl","activerecord","sql","orm"],"license":"MIT","category":"databases-storage","readme_excerpt":"BabySqueel 🐷 Have you ever used the Squeel gem? It's a really nice way to build complex queries. However, Squeel monkeypatches Active Record internals, because it was aimed at enhancing the existing API with the aim of inclusion into Rails. However, that inclusion never happened, and it left Squeel susceptible to breakage from arbitrary changes in Active Record, eventually burning out the maintainer. BabySqueel provides a Squeel-like query DSL for Active Record while hopefully avoiding the majority of the version upgrade difficulties via a minimum of monkeypatching. :heart: Installation Add this line to your application's Gemfile: And then execute: $ bundle Or install it yourself as: $ gem install baby squeel Introduction With Active Record, you might write something like this: But then someone tells you, \"Hey, you should use Arel!\". So you convert your query to use Arel: Well, that's great, but it's also pretty verbose. Why don't you give BabySqueel a try: Quick note BabySqueel's blocks use instance eval , which means you won't have access to your instance variables or methods. Don't worry, there's a really easy solution. Just give arity to the block: Usage Okay, so we have some models: Selects Wheres Orders Joins Grouping Functions Subqueries Exists Custom SQL Operators Querying tables without Active Record models Polymorphism Given this polymorphism: The query might look like this: Helpers Sifters Sifters are like little snippets of conditions that can take arguments. Wha","default_branch":null,"files":null,"tree":[],"storefront":"/r/rzane","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/rzane/baby_squeel/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}