Welcome to RMQL - Ruby on Rails Model Query Language

Some Background

When applications grow after a while sometimes the developers want to open up the application to external developers, to benefit from a total new phenomena - mash-ups. Not that interfaces to applications are something new, but the dynamic of these Web 2.0 mash-ups is incredible.

If the developers start to define the interface they are faced with different questions and problems.

The answer to those question is not easy to find. If the API to the application is exposed using web services both, the generation for servers and generation for consumers is easy to handle, but on the other hand the system breaks, if the API is changed and you will never know if the data that you submit to the consumer is too much or to less.

A Solution!

A solution to the problems described above can be a dynamic interface to the client in a way, that the query send to the server is build and dynamically evaluated.

Now the mash-up developer is able to create statements that fulfill her need and transfers only the amount of data needed to the consumer.

The approach taken in this project is a query language that is based on a very simple subset of XQuery and only allows reading data from a specific Ruby on Rails mdoel.

Give me an example!

You can't wait to see some code?

Lets define the query first. We want to select all Users from a database that have an id smaller then 1000 and return their first and last name.

for $user in User where $user/id < 1000 return
  <user>
    <first_name>{$user/first_name}</first_name>
    <name>{$user/name}</name>
  </user>

Looks cool hmm? Ok, but now what does the answer to this query looks like? Since this will return all users matching the criteria, it returns a list of user statements.

  <user>
    <first_name>Martin</first_name>
    <name>G.</name>
  </user>
  <user>
    <first_name>Peter</first_name>
    <name>P.</name>
  </user>

That looks really easy!

Installation

You can get the most recent version directly from our subversion. Since the whole software is in a beta stage by now this can harm your Rails application if you use it in a productive environment.

To install the plugin in your Rails application execute the following command.

script/plugin install http://rmql.rubyforge.org/svn/trunk/rmql

If you want to use RMQL please have a look at the language guide.