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 +34 -1
- package/dist/browser.cjs +12571 -15635
- package/dist/browser.d.cts +4510 -6314
- package/dist/browser.d.ts +4510 -6314
- package/dist/browser.js +12421 -15484
- package/dist/client.cjs +195 -518
- package/dist/client.d.cts +1930 -3150
- package/dist/client.d.ts +1930 -3150
- package/dist/client.js +194 -514
- package/dist/cloudflare-do.cjs +2403 -3050
- package/dist/cloudflare-do.d.cts +2758 -4209
- package/dist/cloudflare-do.d.ts +2758 -4209
- package/dist/cloudflare-do.js +2402 -3047
- package/dist/cloudflare.cjs +221 -544
- package/dist/cloudflare.d.cts +1931 -3151
- package/dist/cloudflare.d.ts +1931 -3151
- package/dist/cloudflare.js +220 -540
- package/dist/codegen-v2.cjs +115 -426
- package/dist/codegen.cjs +1 -1
- package/dist/format2-worker.js +3405 -3366
- package/dist/index.cjs +11521 -14592
- package/dist/index.d.cts +4396 -6435
- package/dist/index.d.ts +4396 -6435
- package/dist/index.js +11834 -14874
- package/dist/node.cjs +12447 -15473
- package/dist/node.d.cts +5440 -7385
- package/dist/node.d.ts +5440 -7385
- package/dist/node.js +12393 -15393
- package/dist/record-log.cjs +33 -12
- package/dist/record-log.d.cts +40 -5
- package/dist/record-log.d.ts +40 -5
- package/dist/record-log.js +33 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1142,7 +1142,11 @@ const topTags = await Article.aggregate({
|
|
|
1142
1142
|
|
|
1143
1143
|
```typescript
|
|
1144
1144
|
interface AggregationOptions {
|
|
1145
|
-
groupBy: (
|
|
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
|