UNPKG

ravendb

Version:
42 lines 1.3 kB
import { throwError } from "../../Exceptions/index.js"; import { FilterFactory } from "../Queries/FilterFactory.js"; export 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) { 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(this._query, limit); builder(f); } finally { mode.dispose(); } return this; } } //# sourceMappingURL=GroupByDocumentQuery.js.map