GithubHelp home page GithubHelp logo

endor / restful_query Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quirkey/restful_query

1.0 2.0 0.0 333 KB

ActiveRecord extension for querying data in a restful way

Home Page: http://code.quirkey.com/restful_query

License: MIT License

Ruby 100.00%

restful_query's Introduction

restful_query

github.com/quirkey/restful_query

DESCRIPTION:

RestfulQuery provides a RESTful interface for easily and safely querying ActiveRecord data.

USAGE:

Rails/ActiveRecord:

# as a gem, in environment.rb
config.gem 'restful_query'

or install the plugin. In your model:

class Post < ActiveRecord::Base
  can_query
end

In your controller:

class PostsController < ApplicationController
  # ...
  def index
    @posts = Post.restful_query(params[:query])
  end
  # ...
end

Now you can query your model via the URL:

/posts?query[name][like]=jon&query[_sort]=created_at-desc

Sequel

Theres also a Sequel extension that works very similar to ActiveRecord::Base.can_query:

require 'sequel/extensions/restful_query'

DB[:posts].restful_query({'name' => {'like' => 'jon'}, '_sort' => 'created_at-desc'})
<Sequel::SQLite::Dataset: "SELECT * FROM `posts` WHERE (name LIKE %jon%) ORDER BY `created_at` DESC">

More!

Please see the project homepage for detailed usage and info:

code.quirkey.com/restful_query

INSTALL:

To install as a gem:

sudo gem install restful_query

To install as a rails plugin

./script/plugin install git://github.com/quirkey/restful_query.git

LICENSE:

Free for use under the terms of the MIT License - see LICENSE for details

restful_query's People

Contributors

quirkey avatar endor avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.