@lossless.org/client 1.14.0 → 1.15.0
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/nosqldb/classes.collection.d.ts +4 -1
- package/dist_ts/nosqldb/classes.collection.js +7 -2
- package/dist_ts/nosqldb/classes.doc.d.ts +81 -30
- package/dist_ts/nosqldb/classes.doc.js +92 -36
- package/package.json +2 -2
- package/readme.md +4 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/nosqldb/classes.collection.ts +13 -2
- package/ts/nosqldb/classes.doc.ts +227 -70
|
@@ -62,6 +62,13 @@ export interface SvDbOptions {
|
|
|
62
62
|
* below this persisted field.
|
|
63
63
|
*/
|
|
64
64
|
atomicPaths?: readonly string[];
|
|
65
|
+
/**
|
|
66
|
+
* Explicit relative nested paths below this persisted field that hold
|
|
67
|
+
* arrays. Each one is a declared nested path exactly like an `atomicPaths`
|
|
68
|
+
* entry, and in addition the array operators `$push`, `$addToSet` and
|
|
69
|
+
* `$pull` and the grouped-totals `unwind` may target it.
|
|
70
|
+
*/
|
|
71
|
+
arrayPaths?: readonly string[];
|
|
65
72
|
/**
|
|
66
73
|
* Declares this persisted top-level field as numeric for strict atomic
|
|
67
74
|
* expression references.
|
|
@@ -261,16 +268,39 @@ export interface ISmartdataAtomicNumericExpression<T> {
|
|
|
261
268
|
TSmartdataAtomicNumericExpressionOperand<T>
|
|
262
269
|
];
|
|
263
270
|
}
|
|
264
|
-
|
|
271
|
+
/**
|
|
272
|
+
* A path grouped totals may group by or sum: a declared top-level field or a
|
|
273
|
+
* nested path declared through `@svDb({ atomicPaths })` or
|
|
274
|
+
* `@svDb({ arrayPaths })`.
|
|
275
|
+
*/
|
|
276
|
+
export type TSmartdataGroupedTotalsPath<T> = TSmartdataAtomicDocumentPath<T>;
|
|
277
|
+
/**
|
|
278
|
+
* A path grouped totals may unwind: a declared top-level array field or a
|
|
279
|
+
* nested path declared through `@svDb({ arrayPaths })`.
|
|
280
|
+
*/
|
|
281
|
+
export type TSmartdataGroupedTotalsUnwindPath<T> = TSmartdataAtomicArrayPath<T> | TSmartdataAtomicNestedDocumentPath<T>;
|
|
282
|
+
export interface ISmartdataGroupedTotalsOptions<T, TUnwind extends TSmartdataGroupedTotalsUnwindPath<T> = never> {
|
|
265
283
|
/**
|
|
266
|
-
* One or two declared
|
|
267
|
-
*
|
|
284
|
+
* One or two distinct declared paths whose value combinations form the
|
|
285
|
+
* groups: declared top-level fields or nested paths declared through
|
|
286
|
+
* `@svDb({ atomicPaths })` or `@svDb({ arrayPaths })`.
|
|
268
287
|
*/
|
|
269
|
-
groupBy: ReadonlyArray<
|
|
288
|
+
groupBy: ReadonlyArray<TSmartdataGroupedTotalsPath<T>>;
|
|
270
289
|
/**
|
|
271
|
-
*
|
|
290
|
+
* Groups by each element of one array instead of by the array: names
|
|
291
|
+
* exactly one `groupBy` path, which must be a declared top-level array
|
|
292
|
+
* field or a nested path declared through `@svDb({ arrayPaths })`. Every
|
|
293
|
+
* element forms its own row, so `count` counts elements and a document
|
|
294
|
+
* contributes its `sums` once per element; a document whose array is
|
|
295
|
+
* missing, null or empty contributes nothing. The `filter` still selects
|
|
296
|
+
* whole documents before the array is unwound.
|
|
272
297
|
*/
|
|
273
|
-
|
|
298
|
+
unwind?: TUnwind;
|
|
299
|
+
/**
|
|
300
|
+
* Declared numeric top-level fields, or declared nested paths holding
|
|
301
|
+
* numbers, to sum per group.
|
|
302
|
+
*/
|
|
303
|
+
sums?: ReadonlyArray<TSmartdataNumericDocumentPath<T> | TSmartdataAtomicNestedDocumentPath<T>>;
|
|
274
304
|
filter?: MongoFilter<T>;
|
|
275
305
|
/**
|
|
276
306
|
* Required bound on the number of returned groups (1..10000). The group
|
|
@@ -290,32 +320,41 @@ export interface ISmartdataGroupedTotalsOptions<T> {
|
|
|
290
320
|
signal?: AbortSignal;
|
|
291
321
|
session?: TSmartdataOrdinarySession;
|
|
292
322
|
}
|
|
293
|
-
export interface ISmartdataGroupedTotalsRow<T> {
|
|
323
|
+
export interface ISmartdataGroupedTotalsRow<T, TUnwind extends TSmartdataGroupedTotalsUnwindPath<T> = never> {
|
|
294
324
|
/**
|
|
295
|
-
* The group's key values
|
|
296
|
-
* holding an explicit null merge into
|
|
325
|
+
* The group's key values, keyed by the `groupBy` paths as given. Documents
|
|
326
|
+
* missing a group path and documents holding an explicit null merge into
|
|
327
|
+
* one group reported as null. An unwound top-level array reports the
|
|
328
|
+
* element; nested paths report the stored value untyped.
|
|
297
329
|
*/
|
|
298
330
|
group: {
|
|
299
|
-
[TKey in TSmartdataDocumentPath<T>]?: T[TKey] | null;
|
|
300
|
-
}
|
|
331
|
+
[TKey in TSmartdataDocumentPath<T>]?: (TKey extends TUnwind ? TSmartdataAtomicArrayElement<T[TKey]> : T[TKey]) | null;
|
|
332
|
+
} & Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, unknown>>;
|
|
301
333
|
count: number;
|
|
302
|
-
sums: Partial<Record<TSmartdataNumericDocumentPath<T>, number>>;
|
|
334
|
+
sums: Partial<Record<TSmartdataNumericDocumentPath<T> | TSmartdataAtomicNestedDocumentPath<T>, number>>;
|
|
303
335
|
}
|
|
304
|
-
export interface ISmartdataGroupedTotalsPage<T> {
|
|
305
|
-
rows: Array<ISmartdataGroupedTotalsRow<T>>;
|
|
336
|
+
export interface ISmartdataGroupedTotalsPage<T, TUnwind extends TSmartdataGroupedTotalsUnwindPath<T> = never> {
|
|
337
|
+
rows: Array<ISmartdataGroupedTotalsRow<T, TUnwind>>;
|
|
306
338
|
hasMore: boolean;
|
|
307
339
|
}
|
|
308
340
|
export type TSmartdataAtomicArrayPath<T> = {
|
|
309
341
|
[TKey in TSmartdataDocumentPath<T>]: NonNullable<T[TKey]> extends ReadonlyArray<unknown> ? TKey : never;
|
|
310
342
|
}[TSmartdataDocumentPath<T>];
|
|
311
343
|
type TSmartdataAtomicArrayElement<TValue> = NonNullable<TValue> extends ReadonlyArray<infer TElement> ? TElement : never;
|
|
344
|
+
/**
|
|
345
|
+
* Array operators take a declared top-level array field, typed by its element,
|
|
346
|
+
* or a nested path below a declared field. A nested path is accepted at run
|
|
347
|
+
* time only when the model declares it through `@svDb({ arrayPaths })`.
|
|
348
|
+
*/
|
|
312
349
|
type TSmartdataAtomicArrayOperation<T> = Partial<{
|
|
313
350
|
[TKey in TSmartdataAtomicArrayPath<T>]: TSmartdataAtomicArrayElement<T[TKey]>;
|
|
314
|
-
}
|
|
315
|
-
|
|
351
|
+
}> & Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, unknown>>;
|
|
352
|
+
/** The scalar equality operands `$pull` accepts. */
|
|
353
|
+
type TSmartdataAtomicPullScalarValue = string | number | boolean | null | Date | plugins.mongodb.ObjectId | plugins.mongodb.Binary | plugins.mongodb.Decimal128 | plugins.mongodb.Long | plugins.mongodb.Int32 | plugins.mongodb.Double | plugins.mongodb.Timestamp;
|
|
354
|
+
type TSmartdataAtomicPullScalar<TValue> = Extract<TValue, TSmartdataAtomicPullScalarValue>;
|
|
316
355
|
type TSmartdataAtomicArrayPullOperation<T> = Partial<{
|
|
317
356
|
[TKey in TSmartdataAtomicArrayPath<T>]: TSmartdataAtomicPullScalar<TSmartdataAtomicArrayElement<T[TKey]>>;
|
|
318
|
-
}
|
|
357
|
+
}> & Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, TSmartdataAtomicPullScalarValue>>;
|
|
319
358
|
export interface ISmartdataAtomicUpdate<T> {
|
|
320
359
|
$set?: TSmartdataAtomicSet<T>;
|
|
321
360
|
$unset?: Partial<Record<TSmartdataAtomicDocumentPath<T>, '' | true | 1>>;
|
|
@@ -334,19 +373,21 @@ export interface ISmartdataAtomicUpdate<T> {
|
|
|
334
373
|
$min?: TSmartdataAtomicMonotonic<T>;
|
|
335
374
|
$setOnInsert?: TSmartdataAtomicSet<T>;
|
|
336
375
|
/**
|
|
337
|
-
* Appends one element to a declared top-level array field
|
|
338
|
-
*
|
|
376
|
+
* Appends one element to a declared top-level array field or a nested
|
|
377
|
+
* path declared through `@svDb({ arrayPaths })`. Modifier documents
|
|
378
|
+
* ($each, $position, $slice, $sort) are rejected.
|
|
339
379
|
*/
|
|
340
380
|
$push?: TSmartdataAtomicArrayOperation<T>;
|
|
341
381
|
/**
|
|
342
|
-
* Adds one element to a declared top-level array field
|
|
343
|
-
* element is already present. Modifier
|
|
382
|
+
* Adds one element to a declared top-level array field or a declared
|
|
383
|
+
* nested array path unless an equal element is already present. Modifier
|
|
384
|
+
* documents are rejected.
|
|
344
385
|
*/
|
|
345
386
|
$addToSet?: TSmartdataAtomicArrayOperation<T>;
|
|
346
387
|
/**
|
|
347
388
|
* Removes every element equal to a scalar operand from a declared
|
|
348
|
-
* top-level array field
|
|
349
|
-
* regular expressions are rejected.
|
|
389
|
+
* top-level array field or a declared nested array path. Operator
|
|
390
|
+
* documents, plain objects, arrays, and regular expressions are rejected.
|
|
350
391
|
*/
|
|
351
392
|
$pull?: TSmartdataAtomicArrayPullOperation<T>;
|
|
352
393
|
}
|
|
@@ -565,7 +606,14 @@ export declare class SmartDataDbDoc<T extends TImplements, TImplements, TManager
|
|
|
565
606
|
* guarantee at most one matching document for an equality filter.
|
|
566
607
|
*/
|
|
567
608
|
private static getGloballyConstrainingKeySets;
|
|
609
|
+
/**
|
|
610
|
+
* Every nested path the model declares below a persisted field, through
|
|
611
|
+
* `@svDb({ atomicPaths })` or `@svDb({ arrayPaths })`.
|
|
612
|
+
*/
|
|
568
613
|
private static getDeclaredAtomicPaths;
|
|
614
|
+
/** The nested paths declared through `@svDb({ arrayPaths })` as holding arrays. */
|
|
615
|
+
private static getDeclaredArrayPaths;
|
|
616
|
+
private static readDeclaredNestedPaths;
|
|
569
617
|
private static getSerializedPersistedRoots;
|
|
570
618
|
private static getDeclaredQueryPaths;
|
|
571
619
|
private static assertHydratedProjection;
|
|
@@ -703,19 +751,22 @@ export declare class SmartDataDbDoc<T extends TImplements, TImplements, TManager
|
|
|
703
751
|
static atomicUpsertMany<T>(this: plugins.tsclass.typeFest.Class<T>, operationsArg: ReadonlyArray<ISmartdataAtomicUpsertManyOperation<T>>, opts?: ISmartdataAtomicUpsertManyOptions): Promise<ISmartdataAtomicUpsertManyResult>;
|
|
704
752
|
/**
|
|
705
753
|
* Computes bounded grouped counts and optional numeric sums server-side.
|
|
706
|
-
* Groups by one or two declared top-level fields
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
754
|
+
* Groups by one or two declared paths — top-level fields or nested paths
|
|
755
|
+
* declared through `@svDb({ atomicPaths })` or `@svDb({ arrayPaths })` —
|
|
756
|
+
* optionally by each element of one declared array (`unwind`), always
|
|
757
|
+
* returns a `count` per group, and sums only declared numeric paths. The
|
|
758
|
+
* `$limit` follows the group stage without a sort, so when more groups
|
|
759
|
+
* exist than the limit the returned subset is arbitrary. Use
|
|
760
|
+
* `getGroupedTotalsPage()` when the caller must detect overflow. The
|
|
761
|
+
* aggregation cursor never leaves SmartData.
|
|
711
762
|
*/
|
|
712
|
-
static getGroupedTotals<T>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T>): Promise<Array<ISmartdataGroupedTotalsRow<T>>>;
|
|
763
|
+
static getGroupedTotals<T, TUnwind extends TSmartdataGroupedTotalsUnwindPath<T> = never>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T, TUnwind>): Promise<Array<ISmartdataGroupedTotalsRow<T, TUnwind>>>;
|
|
713
764
|
/**
|
|
714
765
|
* Computes the same bounded grouped totals as `getGroupedTotals()` and
|
|
715
766
|
* reports whether at least one additional group exists beyond the requested
|
|
716
767
|
* row limit.
|
|
717
768
|
*/
|
|
718
|
-
static getGroupedTotalsPage<T>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T>): Promise<ISmartdataGroupedTotalsPage<T>>;
|
|
769
|
+
static getGroupedTotalsPage<T, TUnwind extends TSmartdataGroupedTotalsUnwindPath<T> = never>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T, TUnwind>): Promise<ISmartdataGroupedTotalsPage<T, TUnwind>>;
|
|
719
770
|
/**
|
|
720
771
|
* gets all instances as array
|
|
721
772
|
* @param this
|