diff --git a/packages/wasm-sdk/src/queries/document.rs b/packages/wasm-sdk/src/queries/document.rs index 1aec8924c8e..8c8a7856acf 100644 --- a/packages/wasm-sdk/src/queries/document.rs +++ b/packages/wasm-sdk/src/queries/document.rs @@ -99,11 +99,14 @@ export interface DocumentsQuery { startAt?: IdentifierLike /** - * Count-query knob: SQL-shaped `GROUP BY` field list. Mirrors - * the v1 wire's `group_by: repeated string` directly. Ignored - * by the regular document-fetch path. + * Aggregate-query option: SQL-shaped `GROUP BY` field list. Mirrors + * the v1 wire's `group_by: repeated string` directly. Ignored by + * the regular document-fetch path. * - * - `[]` or omitted → aggregate count (a single row). + * - `[]` or omitted → one ungrouped result entry, keyed by the + * empty string. Its value is the total count for + * `getDocumentsCount`, total sum for `getDocumentsSum`, or + * `{count, sum}` for `getDocumentsAverage`. * - `[""]` where `` matches an `In` * constraint → per-`In`-value entries (PerInValue). * - `[""]` where `` matches a range @@ -217,11 +220,11 @@ pub(super) struct DocumentsQueryInput { pub(super) start_after: Option, #[serde(rename = "startAt", default)] pub(super) start_at: Option, - /// Count-query knob: SQL-shaped `GROUP BY` field list, + /// Aggregate-query option: SQL-shaped `GROUP BY` field list, /// mirroring the v1 wire `group_by: repeated string` field /// one-to-one. Ignored by the regular document-fetch path. /// See the TypeScript declaration for the supported shapes. - /// Default empty (aggregate count). + /// Default empty (one ungrouped aggregate result entry). #[serde(rename = "groupBy", default)] pub(super) group_by: Option>, // Order direction for count results flows through the existing @@ -268,8 +271,8 @@ pub(super) async fn build_documents_query( sdk: &WasmSdk, input: DocumentsQueryInput, ) -> Result { - // `group_by` on the shared input struct is a count-query-only - // knob; the regular document-fetch path destructured here just + // `group_by` on the shared input struct is an aggregate-query-only + // option; the regular document-fetch path destructured here just // drops it. let DocumentsQueryInput { data_contract_id,