README.md in query_helper-0.2.21 vs README.md in query_helper-0.2.26

- old
+ new

@@ -1,7 +1,6 @@ # QueryHelper -[![TravisCI](https://travis-ci.org/iserve-products/query_helper.svg?branch=master)](https://travis-ci.org/iserve-products/query_helper) [![Gem Version](https://badge.fury.io/rb/query_helper.svg)](https://badge.fury.io/rb/query_helper) QueryHelper is a ruby gem used to paginate, sort, and filter your API calls in Ruby on Rails using URL params in your HTTP requests. It currently only supports Postgres. ## Installation @@ -86,10 +85,41 @@ Multiple Sorts: `http://www.example.com/resources?sort=resource_name:desc,resource_age:asc` Lowercase Sort: `http://www.example.com/resources?sort=resource_name:desc:lowercase` +Custom Sort: `http://www.example.com/resources?custom_sort=resource_name:desc` +Example: + Custom Sort is basically used for enum based column. + ``` + class Customer < ApplicationRecord + enum customer_type: { + enum1: 0, + enum2: 1, + enum3: 3 + } + end + ``` + + Usage at Controller + + ``` + class SomeController + + def index + sort_column, sort_direction = params[:custom_sort]&.split(':') + + column_sort_order = { + column_name: sort_column, + direction: sort_direction, + sort_values: Customer.send(sort_column.pluralize).values + } + + @query_helper.update(query: query, column_sort_order: column_sort_order) + end + end + ``` #### Filtering `filter[column][operator_code]=value` Single Filter: `http://www.example.com/resources?filter[resource_age][gt]=50` @@ -314,10 +344,10 @@ } ``` ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/iserve_products/query_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. +Bug reports and pull requests are welcome on GitHub at https://github.com/patterninc/query_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).