js-bao 0.12.0-alpha.4 → 0.12.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1142,7 +1142,11 @@ const topTags = await Article.aggregate({
1142
1142
 
1143
1143
  ```typescript
1144
1144
  interface AggregationOptions {
1145
- groupBy: (string | { field: string; contains: string })[];
1145
+ groupBy: (
1146
+ | string // a plain field, or a StringSet facet
1147
+ | { field: string; contains: string } // StringSet membership: has_<field>_<contains>
1148
+ | { field: string; period: "month" | "quarter" | "year" } // date period: <field>_<period>
1149
+ )[];
1146
1150
  operations: {
1147
1151
  type: "count" | "sum" | "avg" | "min" | "max";
1148
1152
  field?: string; // Required for sum, avg, min, max
@@ -1157,6 +1161,22 @@ interface AggregationOptions {
1157
1161
  }
1158
1162
  ```
1159
1163
 
1164
+ A period level groups a `date` (or `string`) field by calendar month, quarter
1165
+ or year. Its value in `group` is `YYYY-MM`, `YYYY-Qn` or `YYYY`, read from the
1166
+ stored text with no time-zone conversion (a UTC ISO timestamp buckets by its
1167
+ UTC date); a missing or non-date value is `null`. The keys sort
1168
+ chronologically, so `sort` can name them:
1169
+
1170
+ ```typescript
1171
+ const monthly = await Transaction.aggregate({
1172
+ filter: { date: { $gte: "2025-11-01", $lte: "2026-10-31" } },
1173
+ groupBy: ["categoryId", { field: "date", period: "month" }],
1174
+ operations: [{ type: "sum", field: "amount" }, { type: "count" }],
1175
+ sort: { field: "date_month", direction: 1 },
1176
+ });
1177
+ // [{ group: { categoryId: "food", date_month: "2025-11" }, sum_amount: -50, count: 2 }, ...]
1178
+ ```
1179
+
1160
1180
  ## StringSet Fields
1161
1181
 
1162
1182
  StringSet is a special field type optimized for tag-like data, providing efficient membership queries and faceting capabilities.
@@ -1576,6 +1596,19 @@ See the `examples/` directory for complete working examples:
1576
1596
  Changes a consumer of this package can observe, including the on-disk
1577
1597
  behaviour of `js-bao/cloudflare/do` (`DurableObjectEngine`). Newest first.
1578
1598
 
1599
+ - **Breaking: format 2 (large document) is removed** (0.12.0). Every
1600
+ `models/format2*` export that served the epoch overlay is gone — the record
1601
+ store and its asynchronous host, the overlay observer and fold, the epoch
1602
+ handoff and rotation, the cold start and snapshot loader, the offline window
1603
+ (`DocumentOfflineWindowError`) and offline replay — with `utils/largeDocuments`
1604
+ and `utils/overlaySql`. `InitJsBaoOptions` loses `largeDocumentStorage` and
1605
+ `InitJsBaoResult` its `format2*` hooks and `whenFormat2ProjectionSettled`;
1606
+ `connectDocument` refuses `documentFormat: 2` with `DOCUMENT_FORMAT_UNSUPPORTED`.
1607
+ The OPFS worker and broker, `Format2StoreSql`, `createFormat2Sql()`,
1608
+ `largeDocumentStoreScope` and the row cache stay: a record-log document
1609
+ (`documentFormat: 3`) runs on them. The worker answers `serve`,
1610
+ `storedEpoch`, `exportLegacy`, `importLegacy` and `dropLegacy` as unknown
1611
+ commands.
1579
1612
  - **Breaking: `createModelClass` is removed** (#4285). It is no longer exported
1580
1613
  from `js-bao` (or re-exported from `js-bao-wss-client`). Define a model as
1581
1614
  `class X extends BaseModel {}` and attach its schema with