Closed nicjansma closed 12 years ago
Try : var q = new joli.query() .select('city, COUNT(*) as count') .from('human') .groupBy('city') .execute('array');
Ah, didn't notice that optional parameter. I'll close this and open a new pull request for a small documentation update.
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 theSELECT
has aCOUNT(*) AS count
result to get the grouping count:In SQL:
In Joli, this doesn't work correctly:
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.