@atscript/db-mongo 0.1.145 → 0.1.147
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/agg.cjs +20 -17
- package/dist/agg.d.cts +7 -4
- package/dist/agg.d.mts +7 -4
- package/dist/agg.mjs +20 -17
- package/dist/index.cjs +472 -177
- package/dist/index.d.cts +90 -22
- package/dist/index.d.mts +90 -22
- package/dist/index.mjs +469 -179
- package/dist/mongo-accumulator-BJcQs2OV.cjs +605 -0
- package/dist/mongo-accumulator-Y_xVYo3C.mjs +534 -0
- package/dist/mongo-filter-CGd9ryOD.d.cts +123 -0
- package/dist/mongo-filter-CGd9ryOD.d.mts +123 -0
- package/package.json +9 -9
- package/dist/mongo-accumulator-BalE9LkU.cjs +0 -265
- package/dist/mongo-accumulator-Dc0w4t0l.mjs +0 -236
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as buildMongoFilter, c as mongoFilterStages, i as TMongoFilterPlan, l as planStages, n as TMongoFieldCollation, o as buildMongoQuery, r as TMongoFilterOptions, s as collationOfAdapter, t as REL_FILTER_TEMP_PREFIX } from "./mongo-filter-CGd9ryOD.cjs";
|
|
2
|
+
import { BaseDbAdapter, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbCollation, TDbDeleteResult, TDbFieldMeta, TDbForeignKey, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbRelation, TDbUpdateResult, TExistingTableOption, TFieldOps, TMetadataOverrides, TPrimaryKeyChange, TSearchIndexInfo, TSyncColumnResult, TTableResolver, TViewCapability, TableMetadata, WithRelation, getKeyProps } from "@atscript/db";
|
|
3
|
+
import { AggregateOptions, AggregationCursor, ClientSession, Collection, Db, Document, Filter, MongoClient, ObjectId, UpdateFilter, UpdateOptions } from "mongodb";
|
|
3
4
|
import { TAtscriptAnnotatedType, TMetadataMap, TValidatorOptions, TValidatorPlugin, Validator } from "@atscript/typescript/utils";
|
|
4
5
|
import { AggregateFn, BucketUnit } from "@uniqu/core";
|
|
5
6
|
|
|
@@ -277,6 +278,12 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
277
278
|
private get _client();
|
|
278
279
|
/** Every adapter over this client (or database handle) shares one session (since 0.1.128). */
|
|
279
280
|
protected _transactionOwner(): unknown;
|
|
281
|
+
/**
|
|
282
|
+
* Same store = same client (or database handle) AND the same database: a
|
|
283
|
+
* `$lookup` only reads collections of the pipeline's own database, and one
|
|
284
|
+
* client may serve several (since 0.1.147).
|
|
285
|
+
*/
|
|
286
|
+
sharesStoreWith(other: BaseDbAdapter): boolean;
|
|
280
287
|
/**
|
|
281
288
|
* Per-client cache: whether transactions are unavailable (standalone MongoDB).
|
|
282
289
|
* Shared across all adapter instances for the same client so topology is probed once.
|
|
@@ -296,7 +303,7 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
296
303
|
session: ClientSession;
|
|
297
304
|
} | Record<string, never>;
|
|
298
305
|
get collection(): Collection<any>;
|
|
299
|
-
aggregatePipeline(pipeline: Document[]): AggregationCursor;
|
|
306
|
+
aggregatePipeline(pipeline: Document[], options?: AggregateOptions): AggregationCursor;
|
|
300
307
|
aggregate(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
301
308
|
get idType(): "string" | "number" | "objectId";
|
|
302
309
|
prepareId(id: unknown, _fieldType: unknown): unknown;
|
|
@@ -307,10 +314,12 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
307
314
|
prepareIdFromIdType<D = string | number | ObjectId>(id: string | number | ObjectId): D;
|
|
308
315
|
supportsNestedObjects(): boolean;
|
|
309
316
|
supportsNativePatch(): boolean;
|
|
310
|
-
/**
|
|
317
|
+
/** Every unit, over MongoDB's bundled time zone database (see `agg.ts` `bucketExpression`). */
|
|
311
318
|
calendarBucketUnits(): ReadonlySet<BucketUnit>;
|
|
312
319
|
/** Every aggregate function, `countDistinct` included. */
|
|
313
320
|
aggregateFns(): ReadonlySet<AggregateFn>;
|
|
321
|
+
/** Computed view columns and first-row joins. */
|
|
322
|
+
viewCapabilities(): ReadonlySet<TViewCapability>;
|
|
314
323
|
/**
|
|
315
324
|
* See BaseDbAdapter.viewRenderRevision. 2 = 0.1.137 (null-guarded field filters, nested document paths).
|
|
316
325
|
* BUMP whenever `buildViewPipeline` output changes for an unchanged view definition.
|
|
@@ -348,6 +357,46 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
348
357
|
} | undefined;
|
|
349
358
|
getAdapterTableName(_type: unknown): string | undefined;
|
|
350
359
|
supportsNativeRelations(): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Relational predicates (`{ nav: { $some | $none: … } }`) render as
|
|
362
|
+
* correlated `$lookup` stages, so a read whose filter holds one runs as an
|
|
363
|
+
* aggregation pipeline (find / count / findManyWithCount / grouped
|
|
364
|
+
* aggregate / search / geo); predicate-free reads keep their plain
|
|
365
|
+
* `find` / `countDocuments` path.
|
|
366
|
+
*
|
|
367
|
+
* Writes (`updateMany` / `replaceMany` / `deleteMany` and the single-row
|
|
368
|
+
* variants, whose scope may carry a predicate) first resolve the matching
|
|
369
|
+
* `_id`s through that pipeline, then write by `_id` in batches of
|
|
370
|
+
* {@link REL_WRITE_BATCH} — re-checking the predicate-free part of the
|
|
371
|
+
* filter. Inside an active transaction both steps share its session and
|
|
372
|
+
* are atomic; without one there is a window between resolving and writing
|
|
373
|
+
* in which a related document can change, so a written document may no
|
|
374
|
+
* longer satisfy the predicate (or a newly matching one is missed).
|
|
375
|
+
*
|
|
376
|
+
* Collation: such a pipeline runs without an operation-wide `collation`
|
|
377
|
+
* (it would govern the join keys and every related field too); each
|
|
378
|
+
* table's `'nocase'` fields are compared case-insensitively explicitly
|
|
379
|
+
* ({@link TMongoFilterOptions.collation}) — on reads and on these writes.
|
|
380
|
+
*
|
|
381
|
+
* @since 0.1.147
|
|
382
|
+
*/
|
|
383
|
+
supportsRelationFilters(_mode: "read" | "write"): boolean;
|
|
384
|
+
/**
|
|
385
|
+
* The `@db.column.collate` of a field (physical or logical path), or
|
|
386
|
+
* `undefined` for a byte-wise one — how predicate pipelines render this
|
|
387
|
+
* table's `'nocase'` comparisons ({@link TMongoFilterOptions.collation}).
|
|
388
|
+
*
|
|
389
|
+
* @since 0.1.147
|
|
390
|
+
*/
|
|
391
|
+
fieldCollation(field: string): TDbCollation | undefined;
|
|
392
|
+
/** Filter-rendering options of a pipeline with relational predicates on this table. */
|
|
393
|
+
private get _predicateFilterOpts();
|
|
394
|
+
/**
|
|
395
|
+
* Operation options of a read: the request collation for a predicate-free
|
|
396
|
+
* filter ({@link _getCollationOpts}); none with relational predicates —
|
|
397
|
+
* those pipelines render collation per field ({@link _predicateFilterOpts}).
|
|
398
|
+
*/
|
|
399
|
+
private _readOpts;
|
|
351
400
|
loadRelations(rows: Array<Record<string, unknown>>, withRelations: WithRelation[], relations: ReadonlyMap<string, TDbRelation>, foreignKeys: ReadonlyMap<string, TDbForeignKey>, tableResolver?: TTableResolver): Promise<void>;
|
|
352
401
|
/** Returns the context object used by CollectionPatcher. */
|
|
353
402
|
getPatcherContext(): TCollectionPatcherContext;
|
|
@@ -394,6 +443,37 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
394
443
|
* rather than silently dropping the CAS predicate.
|
|
395
444
|
*/
|
|
396
445
|
private _buildCasFilter;
|
|
446
|
+
/**
|
|
447
|
+
* The id-resolving pipeline of a write filter holding relational
|
|
448
|
+
* predicates: the matching `_id`s (in the active transaction's session,
|
|
449
|
+
* if any), each table's `'nocase'` fields compared like on reads
|
|
450
|
+
* ({@link _predicateFilterOpts}). `pre` is the predicate-free part, which
|
|
451
|
+
* every `_id`-based write re-checks — so a document that stopped matching
|
|
452
|
+
* it in between is not written.
|
|
453
|
+
*/
|
|
454
|
+
private _predicateWritePlan;
|
|
455
|
+
/** A write filter's `_id` filter (re-checking `pre`). */
|
|
456
|
+
private static _byIds;
|
|
457
|
+
/** Single-document write over a predicate filter: the first match's `_id` filter (`undefined`: none). */
|
|
458
|
+
private _predicateWriteFilterOne;
|
|
459
|
+
/**
|
|
460
|
+
* Multi-document write over `filter`: a predicate-free filter is written
|
|
461
|
+
* as is; one with predicates calls `write` with one `_id`-based filter per
|
|
462
|
+
* batch of {@link REL_WRITE_BATCH} matching ids, streamed from the cursor
|
|
463
|
+
* (never all ids in memory at once).
|
|
464
|
+
*
|
|
465
|
+
* The ids come sorted by `_id`, so writes made while the cursor is open
|
|
466
|
+
* can never feed back into it (otherwise a document an update moves within
|
|
467
|
+
* the index the cursor scans could be returned — and written — twice):
|
|
468
|
+
* after the `$lookup`s that `$sort` consumes every match before the first
|
|
469
|
+
* batch returns, and an `_id` order read from the `_id` index is stable
|
|
470
|
+
* (`_id` never changes).
|
|
471
|
+
*/
|
|
472
|
+
private _forEachMatching;
|
|
473
|
+
/** Runs an update-shaped write over `filter` ({@link _forEachMatching}), counts summed. */
|
|
474
|
+
private _updateMatching;
|
|
475
|
+
/** The filter of a single-document write — its predicates resolved to one `_id`. */
|
|
476
|
+
private _writeFilterOne;
|
|
397
477
|
/**
|
|
398
478
|
* Wraps an async operation to catch MongoDB duplicate key errors
|
|
399
479
|
* (code 11000) and rethrow as structured `DbError` — every write path
|
|
@@ -452,11 +532,16 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
452
532
|
private _getCurrentFieldMax;
|
|
453
533
|
/** Allocates increment values for a batch of items, assigning in order. */
|
|
454
534
|
private _assignBatchIncrements;
|
|
535
|
+
/** A find whose filter holds relational predicates, as an aggregation pipeline. */
|
|
536
|
+
private _aggregateFind;
|
|
455
537
|
private _buildFindOptions;
|
|
456
538
|
/**
|
|
457
539
|
* Returns MongoDB collation options if any filter field has a non-binary collation.
|
|
458
540
|
* Uses pre-computed insights when available, falls back to computing them on demand.
|
|
459
541
|
* Maps: nocase → strength 2 (case-insensitive), unicode → strength 1 (case+accent-insensitive).
|
|
542
|
+
* Predicate-free filters only — a filter with relational predicates never gets an
|
|
543
|
+
* operation-wide collation ({@link _readOpts}), so insights are never computed over
|
|
544
|
+
* resolved predicate operands.
|
|
460
545
|
*/
|
|
461
546
|
private _getCollationOpts;
|
|
462
547
|
protected _addMongoIndexField(type: TPlainIndex["type"], name: string, field: string, weight?: number): void;
|
|
@@ -484,27 +569,10 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
484
569
|
private _descendSearchNode;
|
|
485
570
|
}
|
|
486
571
|
//#endregion
|
|
487
|
-
//#region src/lib/mongo-filter.d.ts
|
|
488
|
-
/**
|
|
489
|
-
* Translates a generic {@link FilterExpr} into a MongoDB-compatible
|
|
490
|
-
* {@link Filter} document.
|
|
491
|
-
*
|
|
492
|
-
* MongoDB's query language is nearly identical to the `FilterExpr` structure,
|
|
493
|
-
* so this is largely a structural pass-through via the `walkFilter` visitor.
|
|
494
|
-
* `fieldOperands` (view predicates only — `translateQueryTree` output) turns
|
|
495
|
-
* `{ $field: path }` operands into field-to-field `$expr` comparisons; a
|
|
496
|
-
* request filter never gets that reading.
|
|
497
|
-
*/
|
|
498
|
-
declare function buildMongoFilter(filter: FilterExpr, {
|
|
499
|
-
fieldOperands
|
|
500
|
-
}?: {
|
|
501
|
-
fieldOperands?: boolean;
|
|
502
|
-
}): Filter<any>;
|
|
503
|
-
//#endregion
|
|
504
572
|
//#region src/lib/validate-plugins.d.ts
|
|
505
573
|
declare const validateMongoIdPlugin: TValidatorPlugin;
|
|
506
574
|
//#endregion
|
|
507
575
|
//#region src/lib/index.d.ts
|
|
508
576
|
declare function createAdapter(connection: string, _options?: Record<string, unknown>): DbSpace;
|
|
509
577
|
//#endregion
|
|
510
|
-
export { CollectionPatcher, INDEX_PREFIX, MongoAdapter, TCollectionPatcherContext, type TMongoIndex, type TMongoSearchIndexDefinition, type TPlainIndex, type TSearchIndex, buildMongoFilter, createAdapter, mongoIndexKey, validateMongoIdPlugin };
|
|
578
|
+
export { CollectionPatcher, INDEX_PREFIX, MongoAdapter, REL_FILTER_TEMP_PREFIX, TCollectionPatcherContext, TMongoFieldCollation, TMongoFilterOptions, TMongoFilterPlan, type TMongoIndex, type TMongoSearchIndexDefinition, type TPlainIndex, type TSearchIndex, buildMongoFilter, buildMongoQuery, collationOfAdapter, createAdapter, mongoFilterStages, mongoIndexKey, planStages, validateMongoIdPlugin };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as buildMongoFilter, c as mongoFilterStages, i as TMongoFilterPlan, l as planStages, n as TMongoFieldCollation, o as buildMongoQuery, r as TMongoFilterOptions, s as collationOfAdapter, t as REL_FILTER_TEMP_PREFIX } from "./mongo-filter-CGd9ryOD.mjs";
|
|
2
|
+
import { BaseDbAdapter, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbCollation, TDbDeleteResult, TDbFieldMeta, TDbForeignKey, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbRelation, TDbUpdateResult, TExistingTableOption, TFieldOps, TMetadataOverrides, TPrimaryKeyChange, TSearchIndexInfo, TSyncColumnResult, TTableResolver, TViewCapability, TableMetadata, WithRelation, getKeyProps } from "@atscript/db";
|
|
3
|
+
import { AggregateOptions, AggregationCursor, ClientSession, Collection, Db, Document, Filter, MongoClient, ObjectId, UpdateFilter, UpdateOptions } from "mongodb";
|
|
3
4
|
import { AggregateFn, BucketUnit } from "@uniqu/core";
|
|
4
5
|
import { TAtscriptAnnotatedType, TMetadataMap, TValidatorOptions, TValidatorPlugin, Validator } from "@atscript/typescript/utils";
|
|
5
6
|
|
|
@@ -277,6 +278,12 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
277
278
|
private get _client();
|
|
278
279
|
/** Every adapter over this client (or database handle) shares one session (since 0.1.128). */
|
|
279
280
|
protected _transactionOwner(): unknown;
|
|
281
|
+
/**
|
|
282
|
+
* Same store = same client (or database handle) AND the same database: a
|
|
283
|
+
* `$lookup` only reads collections of the pipeline's own database, and one
|
|
284
|
+
* client may serve several (since 0.1.147).
|
|
285
|
+
*/
|
|
286
|
+
sharesStoreWith(other: BaseDbAdapter): boolean;
|
|
280
287
|
/**
|
|
281
288
|
* Per-client cache: whether transactions are unavailable (standalone MongoDB).
|
|
282
289
|
* Shared across all adapter instances for the same client so topology is probed once.
|
|
@@ -296,7 +303,7 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
296
303
|
session: ClientSession;
|
|
297
304
|
} | Record<string, never>;
|
|
298
305
|
get collection(): Collection<any>;
|
|
299
|
-
aggregatePipeline(pipeline: Document[]): AggregationCursor;
|
|
306
|
+
aggregatePipeline(pipeline: Document[], options?: AggregateOptions): AggregationCursor;
|
|
300
307
|
aggregate(query: DbQuery): Promise<Array<Record<string, unknown>>>;
|
|
301
308
|
get idType(): "string" | "number" | "objectId";
|
|
302
309
|
prepareId(id: unknown, _fieldType: unknown): unknown;
|
|
@@ -307,10 +314,12 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
307
314
|
prepareIdFromIdType<D = string | number | ObjectId>(id: string | number | ObjectId): D;
|
|
308
315
|
supportsNestedObjects(): boolean;
|
|
309
316
|
supportsNativePatch(): boolean;
|
|
310
|
-
/**
|
|
317
|
+
/** Every unit, over MongoDB's bundled time zone database (see `agg.ts` `bucketExpression`). */
|
|
311
318
|
calendarBucketUnits(): ReadonlySet<BucketUnit>;
|
|
312
319
|
/** Every aggregate function, `countDistinct` included. */
|
|
313
320
|
aggregateFns(): ReadonlySet<AggregateFn>;
|
|
321
|
+
/** Computed view columns and first-row joins. */
|
|
322
|
+
viewCapabilities(): ReadonlySet<TViewCapability>;
|
|
314
323
|
/**
|
|
315
324
|
* See BaseDbAdapter.viewRenderRevision. 2 = 0.1.137 (null-guarded field filters, nested document paths).
|
|
316
325
|
* BUMP whenever `buildViewPipeline` output changes for an unchanged view definition.
|
|
@@ -348,6 +357,46 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
348
357
|
} | undefined;
|
|
349
358
|
getAdapterTableName(_type: unknown): string | undefined;
|
|
350
359
|
supportsNativeRelations(): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Relational predicates (`{ nav: { $some | $none: … } }`) render as
|
|
362
|
+
* correlated `$lookup` stages, so a read whose filter holds one runs as an
|
|
363
|
+
* aggregation pipeline (find / count / findManyWithCount / grouped
|
|
364
|
+
* aggregate / search / geo); predicate-free reads keep their plain
|
|
365
|
+
* `find` / `countDocuments` path.
|
|
366
|
+
*
|
|
367
|
+
* Writes (`updateMany` / `replaceMany` / `deleteMany` and the single-row
|
|
368
|
+
* variants, whose scope may carry a predicate) first resolve the matching
|
|
369
|
+
* `_id`s through that pipeline, then write by `_id` in batches of
|
|
370
|
+
* {@link REL_WRITE_BATCH} — re-checking the predicate-free part of the
|
|
371
|
+
* filter. Inside an active transaction both steps share its session and
|
|
372
|
+
* are atomic; without one there is a window between resolving and writing
|
|
373
|
+
* in which a related document can change, so a written document may no
|
|
374
|
+
* longer satisfy the predicate (or a newly matching one is missed).
|
|
375
|
+
*
|
|
376
|
+
* Collation: such a pipeline runs without an operation-wide `collation`
|
|
377
|
+
* (it would govern the join keys and every related field too); each
|
|
378
|
+
* table's `'nocase'` fields are compared case-insensitively explicitly
|
|
379
|
+
* ({@link TMongoFilterOptions.collation}) — on reads and on these writes.
|
|
380
|
+
*
|
|
381
|
+
* @since 0.1.147
|
|
382
|
+
*/
|
|
383
|
+
supportsRelationFilters(_mode: "read" | "write"): boolean;
|
|
384
|
+
/**
|
|
385
|
+
* The `@db.column.collate` of a field (physical or logical path), or
|
|
386
|
+
* `undefined` for a byte-wise one — how predicate pipelines render this
|
|
387
|
+
* table's `'nocase'` comparisons ({@link TMongoFilterOptions.collation}).
|
|
388
|
+
*
|
|
389
|
+
* @since 0.1.147
|
|
390
|
+
*/
|
|
391
|
+
fieldCollation(field: string): TDbCollation | undefined;
|
|
392
|
+
/** Filter-rendering options of a pipeline with relational predicates on this table. */
|
|
393
|
+
private get _predicateFilterOpts();
|
|
394
|
+
/**
|
|
395
|
+
* Operation options of a read: the request collation for a predicate-free
|
|
396
|
+
* filter ({@link _getCollationOpts}); none with relational predicates —
|
|
397
|
+
* those pipelines render collation per field ({@link _predicateFilterOpts}).
|
|
398
|
+
*/
|
|
399
|
+
private _readOpts;
|
|
351
400
|
loadRelations(rows: Array<Record<string, unknown>>, withRelations: WithRelation[], relations: ReadonlyMap<string, TDbRelation>, foreignKeys: ReadonlyMap<string, TDbForeignKey>, tableResolver?: TTableResolver): Promise<void>;
|
|
352
401
|
/** Returns the context object used by CollectionPatcher. */
|
|
353
402
|
getPatcherContext(): TCollectionPatcherContext;
|
|
@@ -394,6 +443,37 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
394
443
|
* rather than silently dropping the CAS predicate.
|
|
395
444
|
*/
|
|
396
445
|
private _buildCasFilter;
|
|
446
|
+
/**
|
|
447
|
+
* The id-resolving pipeline of a write filter holding relational
|
|
448
|
+
* predicates: the matching `_id`s (in the active transaction's session,
|
|
449
|
+
* if any), each table's `'nocase'` fields compared like on reads
|
|
450
|
+
* ({@link _predicateFilterOpts}). `pre` is the predicate-free part, which
|
|
451
|
+
* every `_id`-based write re-checks — so a document that stopped matching
|
|
452
|
+
* it in between is not written.
|
|
453
|
+
*/
|
|
454
|
+
private _predicateWritePlan;
|
|
455
|
+
/** A write filter's `_id` filter (re-checking `pre`). */
|
|
456
|
+
private static _byIds;
|
|
457
|
+
/** Single-document write over a predicate filter: the first match's `_id` filter (`undefined`: none). */
|
|
458
|
+
private _predicateWriteFilterOne;
|
|
459
|
+
/**
|
|
460
|
+
* Multi-document write over `filter`: a predicate-free filter is written
|
|
461
|
+
* as is; one with predicates calls `write` with one `_id`-based filter per
|
|
462
|
+
* batch of {@link REL_WRITE_BATCH} matching ids, streamed from the cursor
|
|
463
|
+
* (never all ids in memory at once).
|
|
464
|
+
*
|
|
465
|
+
* The ids come sorted by `_id`, so writes made while the cursor is open
|
|
466
|
+
* can never feed back into it (otherwise a document an update moves within
|
|
467
|
+
* the index the cursor scans could be returned — and written — twice):
|
|
468
|
+
* after the `$lookup`s that `$sort` consumes every match before the first
|
|
469
|
+
* batch returns, and an `_id` order read from the `_id` index is stable
|
|
470
|
+
* (`_id` never changes).
|
|
471
|
+
*/
|
|
472
|
+
private _forEachMatching;
|
|
473
|
+
/** Runs an update-shaped write over `filter` ({@link _forEachMatching}), counts summed. */
|
|
474
|
+
private _updateMatching;
|
|
475
|
+
/** The filter of a single-document write — its predicates resolved to one `_id`. */
|
|
476
|
+
private _writeFilterOne;
|
|
397
477
|
/**
|
|
398
478
|
* Wraps an async operation to catch MongoDB duplicate key errors
|
|
399
479
|
* (code 11000) and rethrow as structured `DbError` — every write path
|
|
@@ -452,11 +532,16 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
452
532
|
private _getCurrentFieldMax;
|
|
453
533
|
/** Allocates increment values for a batch of items, assigning in order. */
|
|
454
534
|
private _assignBatchIncrements;
|
|
535
|
+
/** A find whose filter holds relational predicates, as an aggregation pipeline. */
|
|
536
|
+
private _aggregateFind;
|
|
455
537
|
private _buildFindOptions;
|
|
456
538
|
/**
|
|
457
539
|
* Returns MongoDB collation options if any filter field has a non-binary collation.
|
|
458
540
|
* Uses pre-computed insights when available, falls back to computing them on demand.
|
|
459
541
|
* Maps: nocase → strength 2 (case-insensitive), unicode → strength 1 (case+accent-insensitive).
|
|
542
|
+
* Predicate-free filters only — a filter with relational predicates never gets an
|
|
543
|
+
* operation-wide collation ({@link _readOpts}), so insights are never computed over
|
|
544
|
+
* resolved predicate operands.
|
|
460
545
|
*/
|
|
461
546
|
private _getCollationOpts;
|
|
462
547
|
protected _addMongoIndexField(type: TPlainIndex["type"], name: string, field: string, weight?: number): void;
|
|
@@ -484,27 +569,10 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
484
569
|
private _descendSearchNode;
|
|
485
570
|
}
|
|
486
571
|
//#endregion
|
|
487
|
-
//#region src/lib/mongo-filter.d.ts
|
|
488
|
-
/**
|
|
489
|
-
* Translates a generic {@link FilterExpr} into a MongoDB-compatible
|
|
490
|
-
* {@link Filter} document.
|
|
491
|
-
*
|
|
492
|
-
* MongoDB's query language is nearly identical to the `FilterExpr` structure,
|
|
493
|
-
* so this is largely a structural pass-through via the `walkFilter` visitor.
|
|
494
|
-
* `fieldOperands` (view predicates only — `translateQueryTree` output) turns
|
|
495
|
-
* `{ $field: path }` operands into field-to-field `$expr` comparisons; a
|
|
496
|
-
* request filter never gets that reading.
|
|
497
|
-
*/
|
|
498
|
-
declare function buildMongoFilter(filter: FilterExpr, {
|
|
499
|
-
fieldOperands
|
|
500
|
-
}?: {
|
|
501
|
-
fieldOperands?: boolean;
|
|
502
|
-
}): Filter<any>;
|
|
503
|
-
//#endregion
|
|
504
572
|
//#region src/lib/validate-plugins.d.ts
|
|
505
573
|
declare const validateMongoIdPlugin: TValidatorPlugin;
|
|
506
574
|
//#endregion
|
|
507
575
|
//#region src/lib/index.d.ts
|
|
508
576
|
declare function createAdapter(connection: string, _options?: Record<string, unknown>): DbSpace;
|
|
509
577
|
//#endregion
|
|
510
|
-
export { CollectionPatcher, INDEX_PREFIX, MongoAdapter, TCollectionPatcherContext, type TMongoIndex, type TMongoSearchIndexDefinition, type TPlainIndex, type TSearchIndex, buildMongoFilter, createAdapter, mongoIndexKey, validateMongoIdPlugin };
|
|
578
|
+
export { CollectionPatcher, INDEX_PREFIX, MongoAdapter, REL_FILTER_TEMP_PREFIX, TCollectionPatcherContext, TMongoFieldCollation, TMongoFilterOptions, TMongoFilterPlan, type TMongoIndex, type TMongoSearchIndexDefinition, type TPlainIndex, type TSearchIndex, buildMongoFilter, buildMongoQuery, collationOfAdapter, createAdapter, mongoFilterStages, mongoIndexKey, planStages, validateMongoIdPlugin };
|