ravendb
Version:
RavenDB client for Node.js
46 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupByDocumentQuery = void 0;
const index_js_1 = require("../../Exceptions/index.js");
const FilterFactory_js_1 = require("../Queries/FilterFactory.js");
class GroupByDocumentQuery {
_query;
constructor(query) {
this._query = query;
}
selectKey(fieldName = null, projectedName = null) {
this._query._groupByKey(fieldName, projectedName);
return this;
}
selectSum(field, ...fields) {
if (!field) {
(0, index_js_1.throwError)("InvalidArgumentException", "Field cannot be null");
}
this._query._groupBySum(field.fieldName, field.projectedName);
if (!fields || !fields.length) {
return this._query;
}
for (const f of fields) {
this._query._groupBySum(f.fieldName, f.projectedName);
}
return this._query;
}
selectCount(projectedName = "count") {
this._query._groupByCount(projectedName);
return this._query;
}
filter(builder, limit) {
limit ??= Number.MAX_SAFE_INTEGER;
const mode = this._query.setFilterMode(true);
try {
const f = new FilterFactory_js_1.FilterFactory(this._query, limit);
builder(f);
}
finally {
mode.dispose();
}
return this;
}
}
exports.GroupByDocumentQuery = GroupByDocumentQuery;
//# sourceMappingURL=GroupByDocumentQuery.js.map