uql-orm 0.65.1 → 0.67.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/browser/querier/httpQuerier.js +1 -8
- package/dist/browser/uql-browser.min.js.map +5 -5
- package/dist/bunSql/bunSql.util.d.ts +2 -6
- package/dist/bunSql/bunSql.util.js +2 -6
- package/dist/bunSql/bunSqlQuerier.d.ts +2 -5
- package/dist/bunSql/bunSqlQuerier.js +2 -5
- package/dist/cockroachdb/cockroachDialect.d.ts +4 -13
- package/dist/cockroachdb/cockroachDialect.js +4 -13
- package/dist/context/context.browser.js +2 -10
- package/dist/context/context.d.ts +4 -17
- package/dist/context/context.js +4 -17
- package/dist/dialect/abstractDialect.d.ts +4 -19
- package/dist/dialect/abstractDialect.js +2 -20
- package/dist/dialect/abstractSqlDialect.d.ts +47 -212
- package/dist/dialect/abstractSqlDialect.js +68 -222
- package/dist/dialect/aliases.d.ts +2 -12
- package/dist/dialect/aliases.js +4 -12
- package/dist/dialect/hydrateColumn.d.ts +2 -6
- package/dist/dialect/hydrateColumn.js +3 -13
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts +1 -7
- package/dist/dialect/jsonArrayElemMatchUtils.js +1 -7
- package/dist/dialect/jsonSql.d.ts +6 -27
- package/dist/dialect/jsonSql.js +6 -27
- package/dist/dialect/mergeSqlDialect.d.ts +4 -22
- package/dist/dialect/mergeSqlDialect.js +4 -22
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +11 -37
- package/dist/dialect/mysqlLikeSqlDialect.js +35 -51
- package/dist/dialect/pgLikeSqlDialect.d.ts +8 -22
- package/dist/dialect/pgLikeSqlDialect.js +36 -39
- package/dist/dialect/queryContext.d.ts +4 -22
- package/dist/dialect/queryContext.js +4 -22
- package/dist/dialect/queryJoins.d.ts +3 -12
- package/dist/dialect/queryJoins.js +3 -12
- package/dist/dialect/vectorCast.d.ts +2 -12
- package/dist/dialect/vectorCast.js +3 -19
- package/dist/dialect/vectorSqlDialect.d.ts +8 -38
- package/dist/dialect/vectorSqlDialect.js +7 -38
- package/dist/entity/decorator/bag.d.ts +6 -19
- package/dist/entity/decorator/bag.js +6 -22
- package/dist/entity/decorator/entity.d.ts +5 -10
- package/dist/entity/decorator/entity.js +2 -7
- package/dist/entity/decorator/members.d.ts +10 -31
- package/dist/entity/decorator/members.js +3 -12
- package/dist/entity/metadata/definition.d.ts +5 -21
- package/dist/entity/metadata/definition.js +69 -91
- package/dist/http/handler.d.ts +2 -14
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/libsql/libsqlDialect.d.ts +1 -8
- package/dist/libsql/libsqlDialect.js +1 -8
- package/dist/maria/mariaDialect.d.ts +3 -5
- package/dist/maria/mariaDialect.js +5 -5
- package/dist/maria/mariadbQuerier.js +2 -2
- package/dist/maria/mariadbQuerierPool.js +1 -6
- package/dist/migrate/builder/migrationBuilder.js +3 -19
- package/dist/migrate/builder/splitSqlStatements.d.ts +1 -14
- package/dist/migrate/builder/splitSqlStatements.js +2 -22
- package/dist/migrate/builder/types.d.ts +2 -15
- package/dist/migrate/cli-config.js +2 -11
- package/dist/migrate/cli.js +2 -7
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -15
- package/dist/migrate/codegen/entityCodeGenerator.js +15 -44
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +1 -8
- package/dist/migrate/codegen/fieldOptionsSource.js +3 -22
- package/dist/migrate/ddl/indexDdl.d.ts +2 -5
- package/dist/migrate/ddl/indexDdl.js +2 -5
- package/dist/migrate/ddl/pgIndexDdl.d.ts +3 -13
- package/dist/migrate/ddl/pgIndexDdl.js +3 -13
- package/dist/migrate/generator/definitionToNode.d.ts +2 -9
- package/dist/migrate/generator/definitionToNode.js +3 -17
- package/dist/migrate/generator/indexNodeToSchema.d.ts +2 -3
- package/dist/migrate/generator/indexNodeToSchema.js +2 -3
- package/dist/migrate/generator/mongoCommand.d.ts +1 -8
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +1 -8
- package/dist/migrate/generator/mongoSchemaGenerator.js +1 -8
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +6 -26
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +9 -41
- package/dist/migrate/introspection/baseSqlIntrospector.js +0 -1
- package/dist/migrate/introspection/mongoIntrospector.d.ts +3 -1
- package/dist/migrate/introspection/mongoIntrospector.js +48 -46
- package/dist/migrate/introspection/mssqlIntrospector.d.ts +4 -4
- package/dist/migrate/introspection/mssqlIntrospector.js +18 -27
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +7 -2
- package/dist/migrate/introspection/mysqlIntrospector.js +16 -14
- package/dist/migrate/introspection/postgresIntrospector.d.ts +24 -9
- package/dist/migrate/introspection/postgresIntrospector.js +68 -59
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +1 -1
- package/dist/migrate/introspection/sqliteIntrospector.js +8 -10
- package/dist/migrate/migrator.d.ts +9 -53
- package/dist/migrate/migrator.js +32 -65
- package/dist/migrate/schemaGenerator.d.ts +20 -66
- package/dist/migrate/schemaGenerator.js +32 -93
- package/dist/mongo/mongoDialect.d.ts +21 -53
- package/dist/mongo/mongoDialect.js +25 -70
- package/dist/mongo/mongodbQuerier.d.ts +5 -8
- package/dist/mongo/mongodbQuerier.js +31 -65
- package/dist/mssql/mssqlDialect.d.ts +8 -34
- package/dist/mssql/mssqlDialect.js +37 -51
- package/dist/mssql/mssqlQuerier.d.ts +37 -4
- package/dist/mssql/mssqlQuerier.js +2 -2
- package/dist/mssql/mssqlWireTypes.d.ts +2 -14
- package/dist/mssql/mssqlWireTypes.js +2 -14
- package/dist/nestjs/uqlModule.js +2 -7
- package/dist/pglite/pgliteQuerier.d.ts +1 -9
- package/dist/pglite/pgliteQuerierPool.d.ts +4 -26
- package/dist/pglite/pgliteQuerierPool.js +3 -18
- package/dist/postgres/abstractPgQuerierPool.d.ts +1 -8
- package/dist/postgres/abstractPgQuerierPool.js +1 -8
- package/dist/postgres/pgNumericTypes.d.ts +3 -26
- package/dist/postgres/pgNumericTypes.js +3 -26
- package/dist/postgres/postgresDialect.d.ts +4 -10
- package/dist/postgres/postgresDialect.js +4 -10
- package/dist/querier/abstractQuerier.d.ts +35 -103
- package/dist/querier/abstractQuerier.js +105 -201
- package/dist/querier/abstractSharedHandleQuerierPool.d.ts +3 -17
- package/dist/querier/abstractSharedHandleQuerierPool.js +3 -17
- package/dist/querier/abstractSqlQuerier.d.ts +15 -36
- package/dist/querier/abstractSqlQuerier.js +49 -131
- package/dist/schema/canonicalType.d.ts +3 -21
- package/dist/schema/canonicalType.js +22 -67
- package/dist/schema/dependencyGraph.d.ts +2 -8
- package/dist/schema/dependencyGraph.js +2 -32
- package/dist/schema/index.d.ts +1 -25
- package/dist/schema/index.js +0 -26
- package/dist/schema/indexColumns.d.ts +1 -8
- package/dist/schema/indexColumns.js +1 -8
- package/dist/schema/indexDifferences.d.ts +7 -40
- package/dist/schema/indexDifferences.js +6 -31
- package/dist/schema/schemaAST.d.ts +8 -175
- package/dist/schema/schemaAST.js +13 -365
- package/dist/schema/schemaASTBuilder.d.ts +2 -24
- package/dist/schema/schemaASTBuilder.js +6 -41
- package/dist/schema/schemaASTDiffer.d.ts +6 -46
- package/dist/schema/schemaASTDiffer.js +8 -56
- package/dist/schema/types.d.ts +5 -61
- package/dist/schema/types.js +3 -6
- package/dist/sqlite/abstractSqliteQuerier.d.ts +1 -8
- package/dist/sqlite/localSqliteQuerierPool.d.ts +1 -7
- package/dist/sqlite/localSqliteQuerierPool.js +1 -7
- package/dist/sqlite/nodeSqliteQuerierPool.d.ts +2 -7
- package/dist/sqlite/nodeSqliteQuerierPool.js +2 -7
- package/dist/sqlite/sqliteDialect.d.ts +5 -20
- package/dist/sqlite/sqliteDialect.js +29 -35
- package/dist/turso/tursoDialect.d.ts +4 -6
- package/dist/turso/tursoDialect.js +4 -6
- package/dist/turso/tursoLocalQuerierPool.d.ts +1 -7
- package/dist/turso/tursoLocalQuerierPool.js +1 -7
- package/dist/turso/tursoQuerierPool.d.ts +2 -6
- package/dist/turso/tursoQuerierPool.js +2 -6
- package/dist/turso/tursoSessionQuerier.d.ts +1 -7
- package/dist/turso/tursoSessionQuerier.js +1 -7
- package/dist/type/dialect.d.ts +42 -94
- package/dist/type/dialect.js +3 -13
- package/dist/type/entity.d.ts +189 -551
- package/dist/type/entity.js +26 -9
- package/dist/type/logger.d.ts +2 -14
- package/dist/type/migration.d.ts +9 -38
- package/dist/type/querier.d.ts +9 -28
- package/dist/type/querierPool.d.ts +4 -26
- package/dist/type/query.d.ts +28 -78
- package/dist/type/query.js +2 -7
- package/dist/type/queryAggregate.d.ts +18 -98
- package/dist/type/queryRaw.d.ts +1 -8
- package/dist/type/queryRaw.js +1 -8
- package/dist/type/queryWhere.d.ts +13 -61
- package/dist/type/universalQuerier.d.ts +18 -105
- package/dist/type/utility.d.ts +12 -24
- package/dist/type/vector.d.ts +8 -38
- package/dist/type/vector.js +1 -1
- package/dist/type/wire.d.ts +2 -5
- package/dist/util/dialect.util.d.ts +9 -27
- package/dist/util/dialect.util.js +10 -27
- package/dist/util/field.util.d.ts +5 -37
- package/dist/util/field.util.js +7 -50
- package/dist/util/fieldOption.util.d.ts +7 -15
- package/dist/util/fieldOption.util.js +1 -1
- package/dist/util/filters.util.d.ts +2 -5
- package/dist/util/filters.util.js +2 -5
- package/dist/util/logger.d.ts +2 -6
- package/dist/util/logger.js +2 -6
- package/dist/util/object.util.d.ts +2 -6
- package/dist/util/object.util.js +1 -5
- package/dist/util/raw.d.ts +3 -23
- package/dist/util/relationQuery.util.d.ts +3 -14
- package/dist/util/relationQuery.util.js +3 -14
- package/dist/util/rowKey.util.d.ts +2 -10
- package/dist/util/rowKey.util.js +2 -10
- package/dist/util/sql.util.d.ts +6 -37
- package/dist/util/sql.util.js +13 -73
- package/dist/util/sqlLiteral.d.ts +2 -13
- package/dist/util/sqlLiteral.js +8 -13
- package/dist/util/string.util.js +0 -2
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityData, EntityId, ExtraOptions, FieldKey,
|
|
1
|
+
import type { EntityData, EntityId, ExtraOptions, FieldKey, Querier, Query, QueryAggMap, QueryAggregate, QueryAggregateResult, QueryConflictPaths, QueryFilter, QueryFindResult, QueryGroupMap, QueryOneProjected, QueryOptions, QueryPage, QueryProjected, QuerySearch, PrimaryKey, QueryUpdateResult, QueryUpsertOneResult, QueryUpsertManyResult, RelationKey, TransactionOptions, Type, UpdatePayload, WrittenId } from '../type/index.js';
|
|
2
2
|
import { LoggerWrapper } from '../util/index.js';
|
|
3
3
|
/** Base class for all database queriers. */
|
|
4
4
|
export declare abstract class AbstractQuerier implements Querier {
|
|
@@ -18,28 +18,17 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
18
18
|
constructor(extra?: ExtraOptions | undefined);
|
|
19
19
|
protected validateProjectionQuery<E extends object>(entity: Type<E>, q: Query<E>): void;
|
|
20
20
|
private validateProjectionQueryRecursive;
|
|
21
|
-
/**
|
|
22
|
-
* Resolves `[entity, query, opts]` for the dual call pattern: `(entity, q, opts)` (entity argument)
|
|
23
|
-
* vs `(query, opts)` (entity via the query's `$entity` field). Generic in the query `Q` because it
|
|
24
|
-
* only ever reads `$entity`: pinning it to one statement's shape made every caller launder its own
|
|
25
|
-
* through a cast, which is how a read query's `$sort` used to reach a write's.
|
|
26
|
-
*/
|
|
21
|
+
/** `[entity, query, opts]` from either call form, `(entity, q, opts)` or `({ $entity, ...q }, opts)`. */
|
|
27
22
|
protected resolveEntityQuery<E extends object, Q extends object>(entityOrQuery: Type<E> | (Q & {
|
|
28
23
|
$entity: Type<E>;
|
|
29
24
|
}), maybeQueryOrOpts?: Q | QueryOptions, maybeOpts?: QueryOptions): [Type<E>, Q, QueryOptions | undefined];
|
|
30
25
|
findOneById<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(entity: Type<E>, id: EntityId<E>, q?: QueryOneProjected<E, S, V, X, P, C>, opts?: QueryOptions): Promise<QueryFindResult<E, S, V, X, P, C> | undefined>;
|
|
31
|
-
/**
|
|
32
|
-
* Find a single record matching the query.
|
|
33
|
-
* Supports both entity-as-argument and entity-as-field patterns.
|
|
34
|
-
*/
|
|
26
|
+
/** Find one record, the entity passed first or as the query's `$entity`. */
|
|
35
27
|
findOne<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: QueryOneProjected<E, S, V, X, P, C> & {
|
|
36
28
|
$entity: Type<E>;
|
|
37
29
|
}, opts?: QueryOptions): Promise<QueryFindResult<E, S, V, X, P, C> | undefined>;
|
|
38
30
|
findOne<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(entity: Type<E>, q: QueryOneProjected<E, S, V, X, P, C>, opts?: QueryOptions): Promise<QueryFindResult<E, S, V, X, P, C> | undefined>;
|
|
39
|
-
/**
|
|
40
|
-
* Find multiple records matching the query.
|
|
41
|
-
* Supports both entity-as-argument and entity-as-field patterns.
|
|
42
|
-
*/
|
|
31
|
+
/** Find many records, the entity passed first or as the query's `$entity`. */
|
|
43
32
|
findMany<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: QueryProjected<E, S, V, X, P, C> & {
|
|
44
33
|
$entity: Type<E>;
|
|
45
34
|
}, opts?: QueryOptions): Promise<QueryFindResult<E, S, V, X, P, C>[]>;
|
|
@@ -49,20 +38,13 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
49
38
|
* or pipeline. [The design](../../../../architecture/relations-in-one-statement.md).
|
|
50
39
|
*/
|
|
51
40
|
protected abstract internalFindMany<E extends object>(entity: Type<E>, q: Query<E>, opts?: QueryOptions): Promise<E[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Stream records as an async iterable, in both the entity-as-argument and entity-as-field patterns.
|
|
54
|
-
* Each row streams with its populated relations and counts, read by the same statement or pipeline
|
|
55
|
-
* `findMany` runs. No `afterLoad` hooks on streamed rows.
|
|
56
|
-
*/
|
|
41
|
+
/** Stream records with the relations and counts `findMany` reads, the entity passed first or as `$entity`. No hooks fire. */
|
|
57
42
|
findManyStream<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: QueryProjected<E, S, V, X, P, C> & {
|
|
58
43
|
$entity: Type<E>;
|
|
59
44
|
}, opts?: QueryOptions): AsyncIterable<QueryFindResult<E, S, V, X, P, C>>;
|
|
60
45
|
findManyStream<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(entity: Type<E>, q: QueryProjected<E, S, V, X, P, C>, opts?: QueryOptions): AsyncIterable<QueryFindResult<E, S, V, X, P, C>>;
|
|
61
46
|
protected abstract internalFindManyStream<E extends object>(entity: Type<E>, q: Query<E>, opts?: QueryOptions): AsyncIterable<E>;
|
|
62
|
-
/**
|
|
63
|
-
* Find multiple records and return both the records and total count.
|
|
64
|
-
* Supports both entity-as-argument and entity-as-field patterns.
|
|
65
|
-
*/
|
|
47
|
+
/** Find many records and count every match, the entity passed first or as the query's `$entity`. */
|
|
66
48
|
findManyAndCount<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: QueryProjected<E, S, V, X, P, C> & {
|
|
67
49
|
$entity: Type<E>;
|
|
68
50
|
}, opts?: QueryOptions): Promise<[QueryFindResult<E, S, V, X, P, C>[], number]>;
|
|
@@ -72,20 +54,14 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
72
54
|
* backend with no way to answer both at once is left with; SQL overrides it to answer from one.
|
|
73
55
|
*/
|
|
74
56
|
protected internalFindManyAndCount<E extends object>(entity: Type<E>, q: Query<E>, opts?: QueryOptions): Promise<[E[], number]>;
|
|
75
|
-
/**
|
|
76
|
-
* Count records matching the query, in both the entity-as-argument and entity-as-field patterns.
|
|
77
|
-
* A `$skip`/`$limit` settles the matching ids and counts those, rather than scanning every match;
|
|
78
|
-
* `$sort` never reaches that SELECT, since it changes which rows a page holds, never how many.
|
|
79
|
-
*/
|
|
57
|
+
/** Count records matching the query, the entity passed first or as the query's `$entity`. */
|
|
80
58
|
count<E extends object>(entity: Type<E>, q?: QueryPage<E>, opts?: QueryOptions): Promise<number>;
|
|
81
59
|
count<E extends object>(q: QueryPage<E> & {
|
|
82
60
|
$entity: Type<E>;
|
|
83
61
|
}, opts?: QueryOptions): Promise<number>;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* capped at one row, so the engine stops at the first match instead of scanning every other one.
|
|
88
|
-
*/
|
|
62
|
+
/** How many rows match, or how many of them a page takes: counted where they are, never read. */
|
|
63
|
+
protected abstract internalCount<E extends object>(entity: Type<E>, q: QueryPage<E>, opts?: QueryOptions): Promise<number>;
|
|
64
|
+
/** Whether anything matches, the entity passed first or as `$entity`: a count capped at one row. */
|
|
89
65
|
exists<E extends object>(entity: Type<E>, q?: QueryFilter<E>, opts?: QueryOptions): Promise<boolean>;
|
|
90
66
|
exists<E extends object>(q: QueryFilter<E> & {
|
|
91
67
|
$entity: Type<E>;
|
|
@@ -106,38 +82,30 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
106
82
|
/** Writes `rows`, and onto each one the key the database generated for it, where it can tell. */
|
|
107
83
|
protected abstract internalInsertMany<E extends object>(entity: Type<E>, rows: EntityData<E>[]): Promise<void>;
|
|
108
84
|
updateOneById<E extends object>(entity: Type<E>, id: EntityId<E>, payload: UpdatePayload<E>, opts?: QueryOptions): Promise<number>;
|
|
85
|
+
/** Settles the rows first where the update cascades, so a payload changing what `$where` reads still names them. */
|
|
109
86
|
updateMany<E extends object>(entity: Type<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryOptions): Promise<number>;
|
|
87
|
+
/** The UPDATE, skipped where the payload writes no column, reporting `unwritten` instead. */
|
|
88
|
+
private updateColumns;
|
|
89
|
+
/** Whether a write has to name the rows `q` matches by their ids: no engine pages or orders an update or delete. */
|
|
90
|
+
protected settlesWrite<E extends object>(_entity: Type<E>, q: QuerySearch<E>): boolean;
|
|
91
|
+
/** The ids `q` matches, in its own order and page. */
|
|
92
|
+
protected settleIds<E extends object>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions): Promise<EntityId<E>[]>;
|
|
93
|
+
/** Runs one UPDATE over `q`, which names its rows by id wherever {@link updateMany} settled them. */
|
|
110
94
|
protected abstract internalUpdateMany<E extends object>(entity: Type<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryOptions): Promise<number>;
|
|
111
95
|
restoreOneById<E extends object>(entity: Type<E>, id: EntityId<E>): Promise<number>;
|
|
112
96
|
restoreMany<E extends object>(entity: Type<E>, q: QuerySearch<E>): Promise<number>;
|
|
113
|
-
/**
|
|
114
|
-
* `beforeUpsert`/`afterUpsert` rather than the insert's or the update's pair: the database decides
|
|
115
|
-
* which branch each row takes as the statement runs, so neither of those could be fired honestly -
|
|
116
|
-
* but the upsert itself is a fact known before and after, and a row written with no hook at all
|
|
117
|
-
* was how an `@Id({ onInsert })` or an audit trail silently skipped this path.
|
|
118
|
-
*/
|
|
97
|
+
/** Fires `beforeUpsert`/`afterUpsert`: which branch a row takes is the database's to decide, so neither the insert's nor the update's pair fits. */
|
|
119
98
|
upsertOne<E extends object>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityData<E>): Promise<QueryUpsertOneResult<E>>;
|
|
120
99
|
upsertMany<E extends object>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityData<E>[]): Promise<QueryUpsertManyResult<E>>;
|
|
121
100
|
protected abstract internalUpsertOne<E extends object>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityData<E>): Promise<QueryUpdateResult>;
|
|
122
101
|
protected abstract internalUpsertMany<E extends object>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityData<E>[]): Promise<QueryUpdateResult>;
|
|
123
102
|
deleteOneById<E extends object>(entity: Type<E>, id: EntityId<E>, opts?: QueryOptions): Promise<number>;
|
|
124
|
-
/**
|
|
125
|
-
* Delete records matching the query. Soft-deletes when the entity has a soft-delete field (unless
|
|
126
|
-
* `opts.hardDelete`), otherwise removes the rows. Supports both entity-as-argument and entity-as-field patterns.
|
|
127
|
-
*/
|
|
103
|
+
/** Delete records matching the query, the entity passed first or as `$entity`; soft-deletes unless `opts.hardDelete`. */
|
|
128
104
|
deleteMany<E extends object>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions): Promise<number>;
|
|
129
105
|
deleteMany<E extends object>(q: QuerySearch<E> & {
|
|
130
106
|
$entity: Type<E>;
|
|
131
107
|
}, opts?: QueryOptions): Promise<number>;
|
|
132
|
-
/**
|
|
133
|
-
* The rows a delete is about to take, loaded only when a hook or listener is there to receive
|
|
134
|
-
* them: the round trip is pure overhead for the (common) delete nobody is watching, and
|
|
135
|
-
* `internalDeleteMany` has its own fast path that never reads the rows at all.
|
|
136
|
-
*
|
|
137
|
-
* `undefined` means nobody was watching, which is not the same as the empty array meaning nothing
|
|
138
|
-
* matched - the caller deletes by `q` for the first and skips the statement entirely for the second.
|
|
139
|
-
*/
|
|
140
|
-
private findDoomed;
|
|
108
|
+
/** Runs one DELETE (or soft-delete stamp) over `q`, which names its rows by id wherever {@link deleteMany} settled them. */
|
|
141
109
|
protected abstract internalDeleteMany<E extends object>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions): Promise<number>;
|
|
142
110
|
saveOne<E extends object>(entity: Type<E>, payload: EntityData<E>): Promise<WrittenId<E> | undefined>;
|
|
143
111
|
/**
|
|
@@ -146,39 +114,21 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
146
114
|
* inserts. A composite is always named. The hooks follow the statement: a named row fires the upsert pair.
|
|
147
115
|
*/
|
|
148
116
|
saveMany<E extends object>(entity: Type<E>, payload: EntityData<E>[]): Promise<(WrittenId<E> | undefined)[]>;
|
|
149
|
-
|
|
150
|
-
protected
|
|
117
|
+
/** Writes each inserted row's relations, one set of statements per relation whatever the number of rows. */
|
|
118
|
+
protected insertRelations<E extends object>(entity: Type<E>, rows: E[]): Promise<void>;
|
|
119
|
+
/** `EntityId` because a settled composite row is an object, which {@link childrenOf} reads each foreign key column out of. */
|
|
120
|
+
private deleteRelations;
|
|
151
121
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
122
|
+
* Writes each parent's value into one relation. The parent owns what it points at: an update replaces
|
|
123
|
+
* it, and a `null` only clears it.
|
|
154
124
|
*/
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Persists `relValue` against every id in `ids`, which an update hands the whole page of rows it
|
|
158
|
-
* settled: the value is the same for all of them, so the statements are per relation rather than per
|
|
159
|
-
* row wherever the cardinality allows it.
|
|
160
|
-
*/
|
|
161
|
-
protected saveRelation<E extends object>(entity: Type<E>, ids: IdValue<E>[], relValue: unknown, relKey: RelationKey<E>, isUpdate?: boolean): Promise<void>;
|
|
162
|
-
private saveToMany;
|
|
163
|
-
private saveOneToOne;
|
|
125
|
+
private saveRelation;
|
|
126
|
+
/** Each parent gets its own referenced row, and its own column pointing at it. */
|
|
164
127
|
private saveManyToOne;
|
|
165
128
|
abstract readonly hasOpenTransaction: boolean;
|
|
166
129
|
/**
|
|
167
|
-
* Runs `callback` in a transaction
|
|
168
|
-
*
|
|
169
|
-
* The single place that sequence is written; everything else delegates here, because both subtleties
|
|
170
|
-
* below were got wrong by code that hand-rolled it:
|
|
171
|
-
*
|
|
172
|
-
* - `beginTransaction` connects before it begins, so a refused connection lands in the catch with no
|
|
173
|
-
* transaction open. `rollbackTransaction` is a no-op there rather than an error, which is why a
|
|
174
|
-
* wrong password no longer surfaces as a transaction-state error.
|
|
175
|
-
* - A rollback that fails too is a consequence of the original failure, not news, so it must not
|
|
176
|
-
* replace it either.
|
|
177
|
-
*
|
|
178
|
-
* The connection is **not** released here: whoever took it from the pool gives it back, through
|
|
179
|
-
* {@link QuerierPool.transaction}, {@link QuerierPool.withQuerier} or `await using`. Releasing a
|
|
180
|
-
* connection this method never acquired is what forced every caller to know whether it still owned
|
|
181
|
-
* one afterwards.
|
|
130
|
+
* Runs `callback` in a transaction, joining one already open. A rollback that fails is logged, never
|
|
131
|
+
* thrown over the original error, and the connection stays with whoever acquired it.
|
|
182
132
|
*/
|
|
183
133
|
transaction<T>(callback: () => Promise<T>, opts?: TransactionOptions): Promise<T>;
|
|
184
134
|
/** Whether anything at all - a global listener or the entity itself - handles `event`. */
|
|
@@ -205,23 +155,9 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
205
155
|
private hooked;
|
|
206
156
|
/** Fires the global listeners first, then the entity's own hooks. */
|
|
207
157
|
private emitHook;
|
|
208
|
-
/**
|
|
209
|
-
* Runs `task` after everything already queued on this querier, one at a time.
|
|
210
|
-
*
|
|
211
|
-
* @remarks Not re-entrant: only one task runs at a time, so a serialized method awaited from inside
|
|
212
|
-
* another one would wait for a task queued behind itself. Callers below keep their `serialize` calls
|
|
213
|
-
* sequential rather than nested.
|
|
214
|
-
*/
|
|
158
|
+
/** Runs `task` after everything already queued, one at a time. Not re-entrant: never nest `serialize` calls. */
|
|
215
159
|
protected serialize<T>(task: () => Promise<T>): Promise<T>;
|
|
216
|
-
/**
|
|
217
|
-
* Runs `task`, logs `query` with how long it took, and tags any error it throws with that query.
|
|
218
|
-
*
|
|
219
|
-
* A method rather than the `@Log()` decorator it replaces. A standard-spec method decorator works by
|
|
220
|
-
* returning a replacement function, and a replacement cannot carry the original's type parameters, so
|
|
221
|
-
* decorating `internalFindMany<E extends Document>` made its signature unresolvable. Most of the query
|
|
222
|
-
* surface is generic like that, and wrapping at the call site costs one line while keeping the
|
|
223
|
-
* signature intact.
|
|
224
|
-
*/
|
|
160
|
+
/** Runs `task`, logs `query` with its duration, and tags a failure with it: a method, since a decorator would lose the generics. */
|
|
225
161
|
protected timed<T>(query: string, values: unknown[] | undefined, task: () => Promise<T>): Promise<T>;
|
|
226
162
|
abstract beginTransaction(opts?: TransactionOptions): Promise<void>;
|
|
227
163
|
/** Strict: this is the check that catches a forgotten `beginTransaction`. */
|
|
@@ -232,12 +168,8 @@ export declare abstract class AbstractQuerier implements Querier {
|
|
|
232
168
|
*/
|
|
233
169
|
abstract rollbackTransaction(): Promise<void>;
|
|
234
170
|
/**
|
|
235
|
-
* Rolls back an unfinished transaction, then hands the connection back
|
|
236
|
-
*
|
|
237
|
-
* @remarks Refusing to release was the opposite of safe: the throw came *before* the connection went
|
|
238
|
-
* back, so it destroyed the error that got here and cost the pool a connection with a live `BEGIN` on
|
|
239
|
-
* it. It is also the only option `await using` can reach, which calls `Symbol.asyncDispose` with no
|
|
240
|
-
* arguments and discards what it returns.
|
|
171
|
+
* Rolls back an unfinished transaction, then hands the connection back, discarding it if the rollback
|
|
172
|
+
* failed. Never throws first, since `await using` has no other way to release.
|
|
241
173
|
*/
|
|
242
174
|
release(): Promise<void>;
|
|
243
175
|
[Symbol.asyncDispose](): Promise<void>;
|