xavierlacot/joli.js — pull request #21 by nicjansma (2012-03-21 03:14:57+00:00)
Title: asDynamic() method for query results that can't be mapped to a model

Some query results can't (and shouldn't) be mapped back to one of the models. For example, when using a `GROUP BY` statement, if the `SELECT` has a `COUNT(*) AS count` result to get the grouping count:

In SQL:

SELECT city, COUNT(*) as count
FROM human
GROUP BY city

In Joli, this doesn't work correctly:

var q = new joli.query()
.select('city, COUNT(*) as count')
.from('human')
.groupBy('city')
.execute();

Because the result is attempted to map to 'human', which the results are not.

I've added a `.asDynamic()` method that you would add before `.execute()`. If this is set, the results are retuned as a simple property bag instead of as a model.

The documentation was updated as well.