No commit activity in last 3 years
No release in over 3 years
Search the records by attributes of the same table or associated tables. Search: Ex. User.search({search_params: {name: "Alex", city: "New"}, belongs_to: false, has_many: true}) will return the User active relation with conditioning name=Alex and city=new
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.2
 Project Readme

SimpleMysqlApi

TODO: Write a gem description

Installation

Add this line to your application's Gemfile:

gem 'simple_mysql_api', "~> 0.0.4"

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple_mysql_api

Usage

Method name: mysql_search(options={})
options:
Simple search
User.mysql_search({search_params: {name: "alex", address: "new"}})
It will return Users having name matching alex:(mysql like "%alex%") and address matching "new"

Search in associated models

  1. If model has has_many relations with other models then
    Ex. User has_many cities =>
    User.mysql_search({search_params: {name: "alex", city_name_: "new"}, has_many: true})

  2. If model has belongs_to relations with other model then
    Ex. Project belongs_to users =>
    Project.mysql_search({search_params: {name: "my_p", user_name_: "ale"}, belongs_to: true})

  3. Search by ranges(Integer and decimals): Ex. If Item has price field then search for price by range Item.mysql_search({search_params: {price: "1000-2500"}}) # for items having price between 1000 to 2500 Item.mysql_search({search_params: {price: "<2500"}}) # for items having price less than 2500

    Operators: <, >, <= , >=, - #for integer and floating attributes

  4. Search by ranges(Datetime):
    Ex. If Item has posted_at field then search for posted_at by range
    Item.mysql_search({search_params: {posted_at: "2012-09-08 15:28:21 +0530..2012-09-10 15:27:27 +0530"}}) # for items having posted_at date between the given dates
    Item.mysql_search({search_params: {posted_at: "<2012-09-08 15:28:21 +0530"}}) # for items having posted_at date earlier than given date

    Operators: <, >, <= , >=, ..(for range) #for datetime attributes

  5. It joins the tables automatically (Please specify primary & foreign keys if you are using custom keys)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request