uql-orm 0.56.0 → 0.57.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/README.md +1 -1
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +4 -4
- package/dist/cockroachdb/cockroachDialect.d.ts +5 -2
- package/dist/cockroachdb/cockroachDialect.js +2 -10
- package/dist/d1/d1SqliteDialect.d.ts +1 -0
- package/dist/d1/d1SqliteDialect.js +2 -0
- package/dist/dialect/abstractSqlDialect.d.ts +195 -32
- package/dist/dialect/abstractSqlDialect.js +406 -199
- package/dist/dialect/aliases.d.ts +10 -7
- package/dist/dialect/aliases.js +12 -7
- package/dist/dialect/hydrateColumn.d.ts +8 -2
- package/dist/dialect/hydrateColumn.js +33 -1
- package/dist/dialect/jsonSql.d.ts +13 -5
- package/dist/dialect/jsonSql.js +24 -7
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +30 -2
- package/dist/dialect/mysqlLikeSqlDialect.js +56 -4
- package/dist/dialect/pgLikeSqlDialect.d.ts +20 -20
- package/dist/dialect/pgLikeSqlDialect.js +23 -48
- package/dist/dialect/pgVectorMetrics.d.ts +13 -0
- package/dist/dialect/pgVectorMetrics.js +17 -0
- package/dist/dialect/queryContext.d.ts +3 -7
- package/dist/dialect/queryContext.js +13 -8
- package/dist/dialect/queryJoins.d.ts +8 -4
- package/dist/dialect/queryJoins.js +25 -11
- package/dist/dialect/vectorSqlDialect.d.ts +2 -2
- package/dist/dialect/vectorSqlDialect.js +2 -3
- package/dist/entity/metadata/definition.js +3 -3
- package/dist/maria/mariaDialect.d.ts +13 -6
- package/dist/maria/mariaDialect.js +29 -9
- package/dist/migrate/cli.d.ts +2 -3
- package/dist/migrate/cli.js +2 -2
- package/dist/migrate/ddl/index.d.ts +1 -5
- package/dist/migrate/ddl/index.js +14 -25
- package/dist/migrate/ddl/indexDdl.d.ts +11 -2
- package/dist/migrate/ddl/indexDdl.js +17 -1
- package/dist/migrate/ddl/mssqlIndexDdl.d.ts +10 -0
- package/dist/migrate/ddl/mssqlIndexDdl.js +10 -0
- package/dist/migrate/ddl/mysqlIndexDdl.d.ts +10 -17
- package/dist/migrate/ddl/mysqlIndexDdl.js +16 -27
- package/dist/migrate/ddl/pgIndexDdl.d.ts +18 -8
- package/dist/migrate/ddl/pgIndexDdl.js +29 -12
- package/dist/migrate/migrator.d.ts +2 -2
- package/dist/migrate/schemaGenerator.d.ts +3 -3
- package/dist/migrate/schemaGenerator.js +5 -7
- package/dist/migrate/schemaGeneratorAsync.d.ts +2 -3
- package/dist/mongo/mongoDialect.d.ts +30 -17
- package/dist/mongo/mongoDialect.js +143 -101
- package/dist/mongo/mongodbQuerier.d.ts +10 -17
- package/dist/mongo/mongodbQuerier.js +31 -105
- package/dist/mssql/mssqlDialect.d.ts +16 -0
- package/dist/mssql/mssqlDialect.js +26 -4
- package/dist/mysql/mysqlDialect.d.ts +2 -0
- package/dist/mysql/mysqlDialect.js +4 -0
- package/dist/querier/abstractQuerier.d.ts +20 -36
- package/dist/querier/abstractQuerier.js +35 -129
- package/dist/querier/abstractQuerierPool.d.ts +2 -2
- package/dist/querier/abstractSqlQuerier.d.ts +4 -17
- package/dist/querier/abstractSqlQuerier.js +34 -44
- package/dist/schema/canonicalType.js +4 -4
- package/dist/schema/indexDifferences.js +4 -4
- package/dist/schema/schemaASTBuilder.js +31 -2
- package/dist/schema/schemaASTDiffer.js +5 -5
- package/dist/sqlite/sqliteDialect.d.ts +20 -1
- package/dist/sqlite/sqliteDialect.js +38 -7
- package/dist/turso/tursoDialect.d.ts +2 -0
- package/dist/turso/tursoDialect.js +2 -0
- package/dist/type/config.d.ts +2 -2
- package/dist/type/dialect.d.ts +4 -5
- package/dist/type/entity.d.ts +2 -1
- package/dist/type/migratorDialect.d.ts +4 -0
- package/dist/type/querier.d.ts +6 -6
- package/dist/type/query.d.ts +25 -48
- package/dist/type/query.js +10 -5
- package/dist/type/queryAggregate.d.ts +10 -10
- package/dist/type/queryAggregate.js +1 -1
- package/dist/type/universalQuerier.d.ts +4 -4
- package/dist/util/dialect.util.d.ts +1 -1
- package/dist/util/field.util.d.ts +5 -0
- package/dist/util/field.util.js +19 -0
- package/dist/util/object.util.d.ts +2 -0
- package/dist/util/object.util.js +4 -0
- package/dist/util/relationQuery.util.d.ts +12 -65
- package/dist/util/relationQuery.util.js +27 -81
- package/dist/util/rowKey.util.d.ts +1 -11
- package/dist/util/rowKey.util.js +1 -13
- package/package.json +1 -1
- package/dist/querier/relationCount.d.ts +0 -16
- package/dist/querier/relationCount.js +0 -121
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type { PgLikeSqlDialect } from '../../dialect/pgLikeSqlDialect.js';
|
|
2
1
|
import type { IndexColumnSchema, IndexSchema } from '../../type/index.js';
|
|
3
2
|
import { IndexDdl } from './indexDdl.js';
|
|
4
3
|
/** `CREATE INDEX ... USING hnsw ("embedding" vector_cosine_ops) WITH (m = ...)`, pgvector's form. */
|
|
5
|
-
export declare class PgIndexDdl extends IndexDdl
|
|
4
|
+
export declare class PgIndexDdl extends IndexDdl {
|
|
5
|
+
/** Postgres 18's `pg_am`, with pgvector's two. */
|
|
6
|
+
protected readonly indexTypes: Set<"brin" | "btree" | "fulltext" | "gin" | "gist" | "hash" | "hnsw" | "ivfflat" | "vector" | "vectorSearch">;
|
|
7
|
+
protected readonly indexTypeHints: ReadonlyMap<"brin" | "btree" | "fulltext" | "gin" | "gist" | "hash" | "hnsw" | "ivfflat" | "vector" | "vectorSearch", string>;
|
|
6
8
|
protected readonly indexFeatures: Set<"expression" | "include" | "jsonArray" | "jsonPath" | "nullsOrder" | "opsClass" | "partial" | "prefixLength">;
|
|
9
|
+
/** The metrics its vector index takes, each naming the operator class it is built with. */
|
|
10
|
+
protected readonly vectorMetrics: ReadonlyMap<import("../../type/vector.js").VectorDistance, {
|
|
11
|
+
readonly op: string;
|
|
12
|
+
readonly opsSuffix: string;
|
|
13
|
+
}>;
|
|
7
14
|
/** pgvector's own index types; CockroachDB's native one widens this. */
|
|
8
15
|
protected isVectorIndex(index: IndexSchema): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* ` USING <method>`. `fulltext` is refused rather than compiled into a ` USING fulltext` the server
|
|
11
|
-
* can only answer with a syntax error: `$text` computes its `TO_TSVECTOR` per row, which no index
|
|
12
|
-
* over the raw columns serves.
|
|
13
|
-
*/
|
|
14
16
|
protected indexAccessMethod(index: IndexSchema): string;
|
|
15
17
|
/**
|
|
16
18
|
* A vector index's operator class is named `{type}_{metric}_ops`: an index on a `halfvec` column
|
|
@@ -33,9 +35,17 @@ export declare class PgIndexDdl extends IndexDdl<PgLikeSqlDialect> {
|
|
|
33
35
|
*/
|
|
34
36
|
export declare class CockroachIndexDdl extends PgIndexDdl {
|
|
35
37
|
protected readonly indexFeatures: Set<"expression" | "include" | "jsonArray" | "jsonPath" | "nullsOrder" | "opsClass" | "partial" | "prefixLength">;
|
|
38
|
+
/** v26.3 answers `hash` and `brin` "unimplemented", `ivfflat` "unrecognized"; `hnsw` builds its vector index. */
|
|
39
|
+
protected readonly indexTypes: Set<"brin" | "btree" | "fulltext" | "gin" | "gist" | "hash" | "hnsw" | "ivfflat" | "vector" | "vectorSearch">;
|
|
40
|
+
protected readonly indexTypeHints: Map<"brin" | "btree" | "fulltext" | "gin" | "gist" | "hash" | "hnsw" | "ivfflat" | "vector" | "vectorSearch", string>;
|
|
41
|
+
protected readonly vectorMetrics: ReadonlyMap<import("../../type/vector.js").VectorDistance, {
|
|
42
|
+
readonly op: string;
|
|
43
|
+
readonly opsSuffix: string;
|
|
44
|
+
}>;
|
|
36
45
|
private isNativeVectorIndex;
|
|
37
46
|
protected isVectorIndex(index: IndexSchema): boolean;
|
|
38
47
|
protected indexKeyword(index: IndexSchema): string;
|
|
39
48
|
protected indexAccessMethod(index: IndexSchema): string;
|
|
40
|
-
|
|
49
|
+
/** None of pgvector's knobs: `WITH (m = 16)` answers "invalid storage parameter", `hnsw` included. */
|
|
50
|
+
protected indexTuning(): string;
|
|
41
51
|
}
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import { COCKROACH_VECTOR_METRICS, PG_VECTOR_METRICS } from '../../dialect/pgVectorMetrics.js';
|
|
1
2
|
import { unsupportedVectorMetric } from '../../type/vector.js';
|
|
2
3
|
import { IndexDdl } from './indexDdl.js';
|
|
4
|
+
/** `$text` computes its `TO_TSVECTOR` per row, which no index over the raw columns serves. */
|
|
5
|
+
const PG_INDEX_TYPE_HINTS = new Map([
|
|
6
|
+
['fulltext', '. $text needs none there; name the columns it searches with $fields.'],
|
|
7
|
+
]);
|
|
3
8
|
/** `CREATE INDEX ... USING hnsw ("embedding" vector_cosine_ops) WITH (m = ...)`, pgvector's form. */
|
|
4
9
|
export class PgIndexDdl extends IndexDdl {
|
|
10
|
+
/** Postgres 18's `pg_am`, with pgvector's two. */
|
|
11
|
+
indexTypes = new Set([
|
|
12
|
+
'btree',
|
|
13
|
+
'hash',
|
|
14
|
+
'gin',
|
|
15
|
+
'gist',
|
|
16
|
+
'brin',
|
|
17
|
+
'hnsw',
|
|
18
|
+
'ivfflat',
|
|
19
|
+
]);
|
|
20
|
+
indexTypeHints = PG_INDEX_TYPE_HINTS;
|
|
5
21
|
indexFeatures = new Set([
|
|
6
22
|
'expression',
|
|
7
23
|
'partial',
|
|
@@ -10,20 +26,13 @@ export class PgIndexDdl extends IndexDdl {
|
|
|
10
26
|
'include',
|
|
11
27
|
'jsonPath',
|
|
12
28
|
]);
|
|
29
|
+
/** The metrics its vector index takes, each naming the operator class it is built with. */
|
|
30
|
+
vectorMetrics = PG_VECTOR_METRICS;
|
|
13
31
|
/** pgvector's own index types; CockroachDB's native one widens this. */
|
|
14
32
|
isVectorIndex(index) {
|
|
15
33
|
return index.type === 'hnsw' || index.type === 'ivfflat';
|
|
16
34
|
}
|
|
17
|
-
/**
|
|
18
|
-
* ` USING <method>`. `fulltext` is refused rather than compiled into a ` USING fulltext` the server
|
|
19
|
-
* can only answer with a syntax error: `$text` computes its `TO_TSVECTOR` per row, which no index
|
|
20
|
-
* over the raw columns serves.
|
|
21
|
-
*/
|
|
22
35
|
indexAccessMethod(index) {
|
|
23
|
-
if (index.type === 'fulltext') {
|
|
24
|
-
throw new TypeError(`${this.dialect.dialectName} has no fulltext index (index "${index.name}"). $text needs none there; ` +
|
|
25
|
-
'name the columns it searches with $fields.');
|
|
26
|
-
}
|
|
27
36
|
return index.type ? ` USING ${index.type}` : '';
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
@@ -37,7 +46,7 @@ export class PgIndexDdl extends IndexDdl {
|
|
|
37
46
|
if (!this.isVectorIndex(index) || !index.distance) {
|
|
38
47
|
return entry.opsClass ? ` ${entry.opsClass}` : '';
|
|
39
48
|
}
|
|
40
|
-
const metric = this.
|
|
49
|
+
const metric = this.vectorMetrics.get(index.distance);
|
|
41
50
|
if (!metric) {
|
|
42
51
|
throw unsupportedVectorMetric(this.dialect.dialectName, index.distance, index.name);
|
|
43
52
|
}
|
|
@@ -78,6 +87,13 @@ export class PgIndexDdl extends IndexDdl {
|
|
|
78
87
|
*/
|
|
79
88
|
export class CockroachIndexDdl extends PgIndexDdl {
|
|
80
89
|
indexFeatures = new Set(['expression', 'partial', 'include', 'jsonPath']);
|
|
90
|
+
/** v26.3 answers `hash` and `brin` "unimplemented", `ivfflat` "unrecognized"; `hnsw` builds its vector index. */
|
|
91
|
+
indexTypes = new Set(['btree', 'gin', 'gist', 'hnsw', 'vector']);
|
|
92
|
+
indexTypeHints = new Map([
|
|
93
|
+
...PG_INDEX_TYPE_HINTS,
|
|
94
|
+
['ivfflat', "; declare type: 'vector' instead"],
|
|
95
|
+
]);
|
|
96
|
+
vectorMetrics = COCKROACH_VECTOR_METRICS;
|
|
81
97
|
isNativeVectorIndex(index) {
|
|
82
98
|
return index.type === 'vector';
|
|
83
99
|
}
|
|
@@ -90,7 +106,8 @@ export class CockroachIndexDdl extends PgIndexDdl {
|
|
|
90
106
|
indexAccessMethod(index) {
|
|
91
107
|
return this.isNativeVectorIndex(index) ? '' : super.indexAccessMethod(index);
|
|
92
108
|
}
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
/** None of pgvector's knobs: `WITH (m = 16)` answers "invalid storage parameter", `hnsw` included. */
|
|
110
|
+
indexTuning() {
|
|
111
|
+
return '';
|
|
95
112
|
}
|
|
96
113
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DialectName, LoggingOptions, Migration, MigrationDefinition, MigrationResult, MigrationStorage, MigratorOptions, MongoQuerier, Querier, QuerierPool, SchemaDiff, SchemaGenerator, SchemaIntrospector, SyncOptions, Type } from '../type/index.js';
|
|
1
|
+
import type { DialectName, LoggingOptions, Migration, MigrationDefinition, MigrationResult, MigrationStorage, MigratorDialect, MigratorOptions, MongoQuerier, Querier, QuerierPool, SchemaDiff, SchemaGenerator, SchemaIntrospector, SyncOptions, Type } from '../type/index.js';
|
|
2
2
|
import { LoggerWrapper } from '../util/index.js';
|
|
3
3
|
import type { IMigrationBuilder } from './builder/types.js';
|
|
4
4
|
/**
|
|
@@ -18,7 +18,7 @@ export declare class Migrator {
|
|
|
18
18
|
schemaIntrospector?: SchemaIntrospector;
|
|
19
19
|
private readonly _defaultForeignKeyAction?;
|
|
20
20
|
private _mongoSchemaLoadPromise?;
|
|
21
|
-
constructor(pool: QuerierPool, options?: MigratorOptions);
|
|
21
|
+
constructor(pool: QuerierPool<Querier, MigratorDialect>, options?: MigratorOptions);
|
|
22
22
|
/**
|
|
23
23
|
* Loads MongoDB's schema generator on first use, so the optional `mongodb` peer loads only then. SQL
|
|
24
24
|
* generators are set in the constructor (or via {@link setSchemaGenerator}).
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AbstractSqlDialect } from '../dialect/index.js';
|
|
2
2
|
import type { SchemaAST } from '../schema/schemaAST.js';
|
|
3
3
|
import { type DiffOptions } from '../schema/schemaASTDiffer.js';
|
|
4
4
|
import type { CanonicalType, ColumnNode, ForeignKeyAction, IndexNode, TableNode } from '../schema/types.js';
|
|
5
|
-
import type { ColumnSchema, CreateSchemaOptions, DialectFeatures, DropSchemaOptions, EntityMeta, FieldMeta, FieldOptions, ForeignKeySchema, IndexSchema, NamingStrategy, SchemaDiff, SchemaGenerator, SqlDdlGenerator, Type } from '../type/index.js';
|
|
5
|
+
import type { ColumnSchema, CreateSchemaOptions, DialectFeatures, DropSchemaOptions, EntityMeta, FieldMeta, FieldOptions, ForeignKeySchema, IndexSchema, MigratorDialect, NamingStrategy, SchemaDiff, SchemaGenerator, SqlDdlGenerator, Type } from '../type/index.js';
|
|
6
6
|
import type { FullColumnDefinition, TableDefinition } from './builder/types.js';
|
|
7
7
|
import { type IndexDdl, type TableDdl } from './ddl/index.js';
|
|
8
8
|
/**
|
|
@@ -222,4 +222,4 @@ export declare function buildEntityAST(generator: Pick<SchemaGenerator, 'resolve
|
|
|
222
222
|
* Synchronous factory for SQL schema generators only.
|
|
223
223
|
* For MongoDB, use `createSchemaGeneratorAsync` from `./schemaGeneratorAsync.js` so the optional `mongodb` peer is not loaded at import time.
|
|
224
224
|
*/
|
|
225
|
-
export declare function createSchemaGenerator(dialect:
|
|
225
|
+
export declare function createSchemaGenerator(dialect: MigratorDialect, defaultForeignKeyAction?: ForeignKeyAction): SqlSchemaGenerator | undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AbstractSqlDialect } from '../dialect/index.js';
|
|
2
1
|
import { getMeta, soleIdOf } from '../entity/index.js';
|
|
3
|
-
import {
|
|
2
|
+
import { canonicalToSql, engineType, fieldOptionsToCanonical, isVectorCategory } from '../schema/canonicalType.js';
|
|
4
3
|
import { indexSignature } from '../schema/indexDifferences.js';
|
|
5
4
|
import { buildSchemaAST } from '../schema/schemaASTBuilder.js';
|
|
6
5
|
import { diffRelationshipNodes, diffTable } from '../schema/schemaASTDiffer.js';
|
|
@@ -543,8 +542,10 @@ export class SqlSchemaGenerator {
|
|
|
543
542
|
}
|
|
544
543
|
statements.push(createSql);
|
|
545
544
|
statements.push(...this.generateCommentStatements(table));
|
|
545
|
+
// A table created only if missing creates its indexes the same way, or re-creating a schema fails on the first.
|
|
546
|
+
const indexOptions = { ifNotExists: !!options.ifNotExists && this.features.indexIfNotExists };
|
|
546
547
|
for (const idx of table.indexes) {
|
|
547
|
-
statements.push(this.generateCreateIndexFromNode(idx));
|
|
548
|
+
statements.push(this.generateCreateIndexFromNode(idx, indexOptions));
|
|
548
549
|
}
|
|
549
550
|
return statements;
|
|
550
551
|
}
|
|
@@ -726,8 +727,5 @@ export function buildEntityAST(generator, entities, defaultForeignKeyAction) {
|
|
|
726
727
|
* For MongoDB, use `createSchemaGeneratorAsync` from `./schemaGeneratorAsync.js` so the optional `mongodb` peer is not loaded at import time.
|
|
727
728
|
*/
|
|
728
729
|
export function createSchemaGenerator(dialect, defaultForeignKeyAction) {
|
|
729
|
-
|
|
730
|
-
return undefined;
|
|
731
|
-
}
|
|
732
|
-
return new SqlSchemaGenerator(dialect, defaultForeignKeyAction);
|
|
730
|
+
return dialect.dialectName === 'mongodb' ? undefined : new SqlSchemaGenerator(dialect, defaultForeignKeyAction);
|
|
733
731
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { AbstractDialect } from '../dialect/abstractDialect.js';
|
|
2
1
|
import type { ForeignKeyAction } from '../schema/types.js';
|
|
3
|
-
import type { SchemaGenerator } from '../type/index.js';
|
|
2
|
+
import type { MigratorDialect, SchemaGenerator } from '../type/index.js';
|
|
4
3
|
/**
|
|
5
4
|
* Async factory for schema generators. Use this for MongoDB so the optional peer
|
|
6
5
|
* `mongodb` is only loaded when this path runs. SQL dialects delegate to {@link createSchemaGenerator}.
|
|
7
6
|
*/
|
|
8
|
-
export declare function createSchemaGeneratorAsync(dialect:
|
|
7
|
+
export declare function createSchemaGeneratorAsync(dialect: MigratorDialect, defaultForeignKeyAction?: ForeignKeyAction): Promise<SchemaGenerator | undefined>;
|
|
@@ -65,16 +65,18 @@ export declare class MongoDialect extends AbstractDialect {
|
|
|
65
65
|
*/
|
|
66
66
|
private appendRelationLookup;
|
|
67
67
|
/**
|
|
68
|
-
* The correlated `$lookup` for one relation, as `temp`:
|
|
69
|
-
*
|
|
70
|
-
*
|
|
68
|
+
* The correlated `$lookup` for the target rows of one relation `where` narrows, as `temp`: straight at
|
|
69
|
+
* the target, or for a many-to-many from inside its junction's rows. The caller's filter bypass is not
|
|
70
|
+
* passed down, as on the SQL dialects. `tail` decides what the lookup leaves behind - a row to test for
|
|
71
|
+
* existence, or a `$count` - so a filter and an ordering build the same stage.
|
|
71
72
|
*/
|
|
72
73
|
private relationLookup;
|
|
73
74
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
75
|
+
* The junction a many-to-many reaches its targets through: the lookup keys matching a parent's rows of
|
|
76
|
+
* it, its own filters, since a soft-deleted link is not a link, and the field holding each target's id.
|
|
77
|
+
* Each end is one field matched against one `_id`, so both sides must be sole-keyed.
|
|
76
78
|
*/
|
|
77
|
-
private
|
|
79
|
+
private junctionOf;
|
|
78
80
|
/**
|
|
79
81
|
* Compares the looked-up row count, which is `[{ n: <count> }]` or `[]` when nothing matched - hence
|
|
80
82
|
* the `$ifNull` fallback to 0, so `{ $size: 0 }` matches parents with no related row at all.
|
|
@@ -99,7 +101,7 @@ export declare class MongoDialect extends AbstractDialect {
|
|
|
99
101
|
protected mapTableNameRow(row: {
|
|
100
102
|
table_name: string;
|
|
101
103
|
}): string;
|
|
102
|
-
/** String operators
|
|
104
|
+
/** String operators -> { pattern: (v) => regex, caseInsensitive } */
|
|
103
105
|
private static readonly REGEX_OP_MAP;
|
|
104
106
|
/** MongoDB native operators - pass through as-is. */
|
|
105
107
|
private static readonly NATIVE_OPS;
|
|
@@ -127,10 +129,26 @@ export declare class MongoDialect extends AbstractDialect {
|
|
|
127
129
|
* per parent, and the `$set` that lifts the tally onto the document as the field the `$sort` then
|
|
128
130
|
* orders by. A parent with no related row gets no lookup result at all, which is a zero.
|
|
129
131
|
*/
|
|
130
|
-
sortCountStages<E extends Document>(entity: Type<E>, sort: QuerySortMap<E> | undefined
|
|
132
|
+
sortCountStages<E extends Document>(entity: Type<E>, sort: QuerySortMap<E> | undefined): {
|
|
131
133
|
readonly stages: MongoAggregationPipelineEntry<Document>[];
|
|
132
134
|
readonly fields: string[];
|
|
133
135
|
};
|
|
136
|
+
/** The correlated lookup counting a relation's rows, which `where` narrows, into `temp`. */
|
|
137
|
+
private tallyLookup;
|
|
138
|
+
/** The tally a lookup left in `temp`, which holds no row at all where nothing matched: a zero. */
|
|
139
|
+
private tally;
|
|
140
|
+
/**
|
|
141
|
+
* The lookups reading each to-many a query populates, and the tally of each `$count`, onto the fields
|
|
142
|
+
* its rows answer under, and the fields they parked a junction's pairings or a tally on taken back out.
|
|
143
|
+
* [The design](../../../../architecture/relations-in-one-statement.md).
|
|
144
|
+
*/
|
|
145
|
+
private relationReadStages;
|
|
146
|
+
/**
|
|
147
|
+
* A to-many's rows as a lookup running their own read, whose filters, ordering and page apply per
|
|
148
|
+
* parent inside it. A many-to-many reads its targets, each once, by the ids its junction pairs the
|
|
149
|
+
* parent with, parked in a temporary field of the parent's.
|
|
150
|
+
*/
|
|
151
|
+
private toManyLookup;
|
|
134
152
|
/** Whether a `$sort` reads a relation, which is what forces the lookups to run before it. */
|
|
135
153
|
sortsRelations<E extends Document>(entity: Type<E>, sort: QuerySortMap<E> | undefined): boolean;
|
|
136
154
|
/**
|
|
@@ -152,7 +170,7 @@ export declare class MongoDialect extends AbstractDialect {
|
|
|
152
170
|
* Shared by the plain pipeline and the `$vectorSearch` one, which each used to spell the order out
|
|
153
171
|
* for themselves and each got a different part of it wrong.
|
|
154
172
|
*/
|
|
155
|
-
readStages<E extends Document>(entity: Type<E>, q: Query<E>,
|
|
173
|
+
readStages<E extends Document>(entity: Type<E>, q: Query<E>, extra?: MongoReadStages): MongoAggregationPipelineEntry<Document>[];
|
|
156
174
|
/**
|
|
157
175
|
* `$distinct` as a `$group` on the columns the query projects - the same set a SQL dialect puts
|
|
158
176
|
* after `SELECT DISTINCT` - and the `$replaceRoot` that lifts the grouped key back to the top
|
|
@@ -162,16 +180,11 @@ export declare class MongoDialect extends AbstractDialect {
|
|
|
162
180
|
private distinctStages;
|
|
163
181
|
/**
|
|
164
182
|
* The scalar projection a narrowing query asks for, widened by what the pipeline itself produced:
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
183
|
+
* each populated relation and the tallies. It goes last, after the lookups have read the join keys -
|
|
184
|
+
* projecting any earlier is what used to leave `$populate` empty, and is why the pipeline emitted no
|
|
185
|
+
* projection at all and returned every column.
|
|
168
186
|
*/
|
|
169
187
|
pipelineProjection<E extends Document>(entity: Type<E>, q: Query<E>): Record<string, 0 | 1> | undefined;
|
|
170
|
-
/**
|
|
171
|
-
* `$lookup`/`$unwind` stages for the joinable relations a query populates. Shared by the plain
|
|
172
|
-
* aggregation pipeline and the `$vectorSearch` one, so relations load the same way in both.
|
|
173
|
-
*/
|
|
174
|
-
relationStages<E extends Document>(entity: Type<E>, q: Query<E>, opts?: QueryOptions): MongoAggregationPipelineEntry<E>[];
|
|
175
188
|
/**
|
|
176
189
|
* The `$lookup`/`$unwind` pair for each relation joined below `parent`, its own relations nested
|
|
177
190
|
* inside its pipeline and resolved before the projection that reads them.
|