Permalink
Browse files

added distinct aggregation

  • Loading branch information...
1 parent a242cd6 commit 4670f76ddc2663e07427cae5d43cfee7cf23b82f @grob committed Jan 13, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/sqlstore/query.js
View
@@ -420,6 +420,17 @@ Query.prototype.sum = function(property) {
};
/**
+ * Returns only the distinct values of the given property
+ * @param {String} property The property name
+ * @returns The sum
+ */
+Query.prototype.distinct = function(property) {
+ var [sql, parameters] = this.toSql(property, "DISTINCT");
+ var collector = this.store.getCollector(this.mapping, property);
+ return this.store.executeQuery(sql, parameters, collector);
+};
+
+/**
* Adds an "equals"-clause to this query
* @param {String} property The property
* @param {Object} value The value. If the value is an array, the clause added

0 comments on commit 4670f76

Please sign in to comment.