SMQL is a JSON-based query langauage similar to MQL. This gem convertes these querys to ActiveRecord.
Go to file
2011-11-21 10:06:46 +01:00
lib aliased tables. firm: { "people[users]": {type: "User"}, "people[old]": {"age>:": 50 } # Every ToDo which has a User as Person or people older than 50. It is not an OR, it is an AND, but {people:{type:"User","age>":50}} or {"people":{type:"User"},"people":{"age>:":50} means every User older than 50. "users" and "old" are independet questions and both must be present, if firm should be true. 2011-11-21 10:06:46 +01:00
.gitignore AR-through-reflections in query_builder; SmqlToAR.models returns the reflections-graph; limit, offset, sub-query "()" (not sub-conditions). unstable 0.3 2011-09-27 16:35:49 +02:00
AUTHORS init 2011-09-08 17:03:52 +02:00
LICENSE init 2011-09-08 17:03:52 +02:00
Rakefile AR-through-reflections in query_builder; SmqlToAR.models returns the reflections-graph; limit, offset, sub-query "()" (not sub-conditions). unstable 0.3 2011-09-27 16:35:49 +02:00
README.md readme: translationfixes 2011-09-09 00:05:43 +02:00
TODO init 2011-09-08 17:03:52 +02:00
VERSION Version 0.0.4.3 2011-10-27 15:22:49 +02:00

Idea

Similar to MQL: SMQL allows to perform queries on your database but in a JSON-based language.

This query language is SQL-injection-safe. However, expensive queries can slow down your machine.

Usage

Example: An easy query in ruby: User is a ActiveRecord-Model and has a column username. We want to find all users where username = "auser".

require 'smql'

SmqlToAR.to_ar User, '{"username": "auser"}' # Query in JSON
SmqlToAR.to_ar User, username: "auser"       # Query in Ruby

In Rails:

SmqlToAR.to_ar User, params[:smql]

Don't forget to add my gem to the Gemfile:

gem 'smql'