uql-orm 0.103.1 → 0.104.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.
@@ -1,7 +1,7 @@
1
1
  import type { EntityMeta, EntityPredicate, UpdatePayload } from './entity.js';
2
2
  import type { EngineName } from './querier.js';
3
3
  import type { Query, QueryConflictPaths, QueryPage, QueryRenderOptions, QuerySearch, RelationQuery } from './query.js';
4
- import type { QueryAggMap, QueryAggregate, QueryAggregateOp, QueryGroupMap } from './queryAggregate.js';
4
+ import type { QueryAggregate, QueryAggregateOp } from './queryAggregate.js';
5
5
  import type { QuerySqlRenderOptions } from './querySql.js';
6
6
  import type { QueryWhere } from './queryWhere.js';
7
7
  import type { Type } from './utility.js';
@@ -373,7 +373,7 @@ export interface SqlQueryDialect {
373
373
  /**
374
374
  * Build an aggregate query.
375
375
  */
376
- aggregate<E, G extends QueryGroupMap<E>, A extends QueryAggMap<E>>(ctx: QueryContext, entity: Type<E>, q: QueryAggregate<E, G, A>, opts?: QueryRenderOptions): void;
376
+ aggregate<E>(ctx: QueryContext, entity: Type<E>, q: QueryAggregate<E>, opts?: QueryRenderOptions): void;
377
377
  /**
378
378
  * Get the placeholder for a parameter at the given index (1-based).
379
379
  * Default: '?' for MySQL/MariaDB/SQLite, '$n' for PostgreSQL.
@@ -13,6 +13,21 @@ export declare const idKey: unique symbol;
13
13
  * must not start demanding one.
14
14
  */
15
15
  export declare const versionKey: unique symbol;
16
+ /** Brands the fields an insert may leave out, which a default fills, `[filledKey]?: 'units' | 'createdAt'`; each stays present on every read. */
17
+ export declare const filledKey: unique symbol;
18
+ type EntityBrand = typeof idKey | typeof versionKey | typeof filledKey;
19
+ /** The names an entity's brand `B` lists, `never` where it declares none. */
20
+ type BrandNames<E, B extends EntityBrand> = E extends {
21
+ readonly [K in B]?: infer N;
22
+ } ? N : never;
23
+ /**
24
+ * A brand naming a key that is no field, which each reader would drop silently: refused where an entity
25
+ * registers, `@Entity()` or `defineEntity`, by a member the class lacks that names the typo. A class with no
26
+ * members matches every optional brand, so only one declaring a brand is read.
27
+ */
28
+ export type BrandsNameFields<E> = {
29
+ readonly [N in Exclude<[EntityBrand & keyof E] extends [never] ? never : BrandNames<E, EntityBrand>, FieldKey<E>> & string as `brand names '${N}', which is no field`]: never;
30
+ };
16
31
  /** The filter `@Field({ softDelete })` registers, a name reserved against an entity's own filters. */
17
32
  export declare const SOFT_DELETE_FILTER = "softDelete";
18
33
  /** A filter name an entity may declare: any but {@link SOFT_DELETE_FILTER}, which a refusal names. */
@@ -37,10 +52,10 @@ export type WritableKey<E> = {
37
52
  }[FieldKey<E>];
38
53
  /**
39
54
  * What an insert may leave out however the entity declares it: a single-column key, which something
40
- * usually generates, and the version, which uql starts at 0. A composite key is the references a row is
41
- * made of, so an insert names it.
55
+ * usually generates, the version, which uql starts at 0, and what {@link filledKey} lists. A composite
56
+ * key is the references a row is made of, so an insert names it.
42
57
  */
43
- type FilledKey<E> = SoleIdKey<E> | VersionKey<E>;
58
+ type FilledKey<E> = SoleIdKey<E> | VersionKey<E> | (BrandNames<E, typeof filledKey> & FieldKey<E>);
44
59
  /**
45
60
  * A whole-record write as a caller supplies one: {@link EntityData} without the fields it cannot write,
46
61
  * a {@link FilledKey} optional. That part is a conditional, which TypeScript leaves shut while it types a
@@ -6,6 +6,8 @@ export const idKey = Symbol('idKey');
6
6
  * must not start demanding one.
7
7
  */
8
8
  export const versionKey = Symbol('versionKey');
9
+ /** Brands the fields an insert may leave out, which a default fills, `[filledKey]?: 'units' | 'createdAt'`; each stays present on every read. */
10
+ export const filledKey = Symbol('filledKey');
9
11
  /** The filter `@Field({ softDelete })` registers, a name reserved against an entity's own filters. */
10
12
  export const SOFT_DELETE_FILTER = 'softDelete';
11
13
  /** Every SQL column type a field may declare, by family: the unions below and `columnFamily` both read it. */
@@ -1,13 +1,12 @@
1
1
  import type { AbstractSqlDialect } from '../dialect/index.js';
2
2
  import type { SqlDialectName } from './dialect.js';
3
- import type { FieldKey, HookEvent, RelationKey } from './entity.js';
3
+ import type { FieldKey, HookEvent } from './entity.js';
4
4
  import type { LoggingOptions } from './logger.js';
5
5
  import type { NamingStrategy } from './namingStrategy.js';
6
- import type { QueryFilter, QueryFindResult, QueryOptions, QueryPage, QuerySearch, QueryUpdateResult, ReturningResult, WriteOptions } from './query.js';
7
- import type { SqlStatement } from './querySql.js';
8
- import type { ProjectedQuery, ProjectedRead, ProjectedResult, UniversalQuerier } from './universalQuerier.js';
6
+ import type { Captured, QueryFilter, QueryFindResult, QueryOptions, QueryPage, QuerySearch, QueryUpdateResult, WriteResults, WriteOptions } from './query.js';
7
+ import type { QuerySql, SqlStatement } from './querySql.js';
8
+ import type { EntityRead, ReadResults, ReadQueries, UniversalQuerier } from './universalQuerier.js';
9
9
  import type { BooleanLike, RawRow, Type } from './utility.js';
10
- import type { QuerierSql } from './wire.js';
11
10
  /**
12
11
  * Isolation levels for transactions.
13
12
  */
@@ -42,13 +41,15 @@ export declare const ENGINE_NAMES: {
42
41
  /** An engine as a message names it: a dialect's, or a platform running one, as Cloudflare D1 runs SQLite and Neon Postgres. */
43
42
  export type EngineName = (typeof ENGINE_NAMES)[DialectName] | 'Cloudflare D1' | 'Neon';
44
43
  /**
45
- * A projected read that takes the entity first or as the query's `$entity`. The `$entity` form comes
44
+ * A read that takes the entity first or as the query's `$entity`. The `$entity` form comes
46
45
  * **first** on purpose: when no signature matches, TypeScript reports the error of the *last* one, so a
47
46
  * typo'd query key is reported as itself rather than as a missing `$entity`.
48
47
  */
49
- type DualRead<Q extends keyof ProjectedQuery<object, never, never, never, never, never, never>, R extends keyof ProjectedResult<'server', unknown>> = (<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: ProjectedQuery<E, S, V, X, P, C, QuerierSql<'server'>>[Q] & {
48
+ type DualRead<K extends keyof ReadQueries<object, never>, R extends keyof ReadResults<'server', unknown>> = (<E extends object, const Q extends ReadQueries<E, QuerySql>[K] & {
50
49
  $entity: Type<E>;
51
- }, opts?: QueryOptions) => ProjectedResult<'server', QueryFindResult<E, S, V, X, P, C>>[R]) & ProjectedRead<Q, R, 'server', QueryOptions>;
50
+ }>(q: Captured<ReadQueries<E, QuerySql>[K] & {
51
+ $entity: Type<E>;
52
+ }, Q>, opts?: QueryOptions) => ReadResults<'server', QueryFindResult<E, Q>>[R]) & EntityRead<K, R, 'server', QueryOptions>;
52
53
  /** The reads, counts and deletes below take the entity first or as the query's `$entity`, as {@link DualRead} does. */
53
54
  export interface Querier extends UniversalQuerier {
54
55
  findOne: DualRead<'one', 'one'>;
@@ -73,7 +74,7 @@ export interface Querier extends UniversalQuerier {
73
74
  deleteMany<E extends object>(q: QuerySearch<E> & {
74
75
  $entity: Type<E>;
75
76
  }, opts?: QueryOptions): Promise<number>;
76
- deleteMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<ReturningResult<S, number, QueryFindResult<E, S, V>[]>>;
77
+ deleteMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['affectedMany']>;
77
78
  /**
78
79
  * whether this querier is in a transaction or not.
79
80
  */
@@ -1,4 +1,4 @@
1
- import type { FieldKey, FieldKeyOf, JsonFieldPaths, RelationKey, RelationTarget, ToManyRelationKey } from './entity.js';
1
+ import type { FieldKey, FieldKeyOf, JsonFieldPaths, RelationKey, RelationTarget, ToManyRelationKey, WrittenId } from './entity.js';
2
2
  import type { QueryLock } from './queryLock.js';
3
3
  import type { QuerySql } from './querySql.js';
4
4
  import type { QueryWhere } from './queryWhere.js';
@@ -43,7 +43,7 @@ export type QueryRenderOptions = QueryOptions & {
43
43
  /**
44
44
  * Field selection - `{ name: true }` whitelists fields; relations go in `$populate`. Declared over
45
45
  * `F extends keyof E`, like every map keyed by an entity's members, so each key stays linked to its
46
- * property and an editor rename reaches it. `F` is also how a projection passes its captured key set.
46
+ * property and an editor rename reaches it.
47
47
  */
48
48
  export type QuerySelect<E, F extends keyof E = FieldKey<E>, V = BooleanLike> = {
49
49
  [K in F]?: V;
@@ -368,24 +368,11 @@ export type QueryOne<E, Sql = QuerySql> = Except<Query<E, Sql>, '$limit'>;
368
368
  */
369
369
  export type QueryUnique<E, Sql = QuerySql> = Pick<QueryOne<E, Sql>, '$select' | '$exclude' | '$populate' | '$where'>;
370
370
  /**
371
- * The clauses that shape a row, captured as key sets rather than maps: a naked type parameter skips
372
- * excess-property checks, while a key set fails its own constraint on a typo.
373
- * @internal
371
+ * A query as a read captures it: `Q` is inferred from the literal, so the row sees every clause at every
372
+ * depth, while the parameter is `Concrete` itself, so a typo'd key fails its excess-property check at any
373
+ * depth too. A query assembled elsewhere, typed `Concrete`, captures nothing and reads the whole entity.
374
374
  */
375
- type QueryProjection<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E>, Sql = QuerySql> = {
376
- $select?: QuerySelect<E, S, V> | readonly Sql[];
377
- $exclude?: QuerySelect<E, X, V>;
378
- $populate?: QueryPopulate<E, Sql, P>;
379
- $count?: QueryCount<E, Sql, C & ToManyRelationKey<E>>;
380
- };
381
- /**
382
- * A {@link Query} whose projection is captured, so {@link QueryFindResult} can shape the row.
383
- */
384
- export type QueryProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = Query<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
385
- /**
386
- * A {@link QueryOne} whose projection is captured, so {@link QueryFindResult} can shape the row.
387
- */
388
- export type QueryOneProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = QueryOne<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
375
+ export type Captured<Concrete, Q> = Concrete extends Q ? Q : Concrete;
389
376
  /**
390
377
  * The query `findManyPage` takes: a {@link Query} paged by cursor instead of offset, so it has no `$skip` and
391
378
  * `$limit` is the page size. `$after` reads the page after a cursor, `$before` the page before it.
@@ -398,8 +385,6 @@ export type QueryKeyset<E, Sql = QuerySql> = Except<Query<E, Sql>, '$skip'> & {
398
385
  /** A page's `startCursor`, to read the rows before it. */
399
386
  $before?: string;
400
387
  };
401
- /** A {@link QueryKeyset} with its projection captured, so {@link QueryFindResult} can narrow the row. */
402
- export type QueryKeysetProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = QueryKeyset<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
403
388
  /**
404
389
  * One page of `findManyPage`. Each cursor is opaque, and absent on an empty page. The flag in the reading
405
390
  * direction is exact. The other one only says whether the page was read from a cursor (`hasPrevPage` forward,
@@ -415,47 +400,112 @@ export type CursorPage<T> = {
415
400
  readonly hasPrevPage: boolean;
416
401
  };
417
402
  /**
418
- * The keys a query comes back with, as the runtime projects them: a positive `$select`'s, or every
419
- * field minus what `$select` or `$exclude` subtracts, plus the populated relations.
420
- * @internal
403
+ * A find's row: the entity narrowed to what the query `Q` projected and populated, at every depth, so
404
+ * reading anything else does not compile. The entity itself where nothing narrows it. A key union names
405
+ * a projection by hand. `K` is internal: `Q` whole, for a key union the test on `Q` distributes over.
406
+ * @example `QueryFindResult<User, 'id' | 'name'>`, `QueryFindResult<User, typeof query>`
421
407
  */
422
- type ProjectedKeys<E, S, V, X, P> = ([V] extends [false | 0] ? Exclude<FieldKey<E>, S> : [S] extends [never] ? Exclude<FieldKey<E>, X> : S) | P;
423
- /**
424
- * Whether every entry of the captured map says the same thing: all selected, or all subtracted.
425
- * @internal
426
- */
427
- type IsUniform<V> = [V] extends [true | 1] ? true : [V] extends [false | 0] ? true : false;
428
- /**
429
- * A find's row: the entity narrowed to what the query projected and populated, so reading anything
430
- * else does not compile. The entity itself where the projection is raw, absent or not uniform.
431
- * @example `QueryFindResult<User, 'id' | 'name'>`
432
- */
433
- export type QueryFindResult<E, S extends FieldKey<E> = never, V = true, X extends FieldKey<E> = never, P extends RelationKey<E> = never, C extends RelationKey<E> = never> = QueryProjectedRow<E, S, V, X, P, C> & CountedRelations<C>;
408
+ export type QueryFindResult<E, Q = {}, K extends Q = Q> = Q extends ShapingQuery ? ShapedRow<E, Q> : [K] extends [PropertyKey] ? Pick<E, K & keyof E> : E;
409
+ /** The clauses that shape a row; a query naming none of them reads the entity as it is. */
410
+ type ShapingQuery = {
411
+ readonly $select: object;
412
+ } | {
413
+ readonly $exclude: object;
414
+ } | {
415
+ readonly $populate: object;
416
+ } | {
417
+ readonly $count: object;
418
+ };
434
419
  /**
435
- * The `_count` a query asked for, or an inert intersection member when it asked for none - so a read
436
- * without `$count` keeps exactly the row type it had.
437
- */
438
- type CountedRelations<C extends PropertyKey> = [C] extends [never] ? unknown : {
439
- [K in typeof COUNT_RESULT_KEY]: {
440
- [R in C]: number;
441
- };
420
+ * A nested relation's row, as {@link QueryFindResult} without the key-union form. Every alias layer and
421
+ * conditional from here down is paid on each read, measured with `bun run ts.perf`.
422
+ */
423
+ type FindRow<E, Q> = Q extends ShapingQuery ? ShapedRow<E, Q> : E;
424
+ /**
425
+ * The row's own fields, and its relations beside them. A positive `$select` entry wins outright at runtime, so a
426
+ * map with one selects its positive keys alone; one with none subtracts, as a truthy `$exclude` entry does. `Pick`,
427
+ * not a key remap: an entity keyed by an index signature, a content type defined at runtime, has `string` for its
428
+ * keys, which a remap drops.
429
+ */
430
+ type ShapedRow<E, Q> = Q extends {
431
+ readonly $select: infer M;
432
+ } ? (M extends readonly unknown[] ? WholeRow<E, Q> : M[keyof M] extends true | 1 ? Pick<E, ([keyof M] extends [never] ? FieldKey<E> : keyof M) & keyof E> : M[keyof M] extends Off ? Pick<E, Exclude<FieldKey<E>, keyof M> & keyof E> : Pick<E, OnKeys<M> & keyof E> & MaybeFields<E, M>) & RelatedRows<E, Q> : Q extends {
433
+ readonly $exclude: infer M;
434
+ } ? (M[keyof M] extends true | 1 ? Pick<E, Exclude<FieldKey<E>, keyof M> & keyof E> : Pick<E, Exclude<FieldKey<E>, OnKeys<M> | MaybeKeys<M>> & keyof E> & MaybeFields<E, M>) & RelatedRows<E, Q> : WholeRow<E, Q> & RelatedRows<E, Q>;
435
+ type Off = false | 0 | undefined;
436
+ /** The keys of a clause's map whose entry asks for something. */
437
+ type OnKeys<M> = {
438
+ [K in keyof M]-?: [Extract<M[K], Off>] extends [never] ? K : never;
439
+ }[keyof M];
440
+ /** The keys whose entry may or may not ask, a `boolean`: what they name may be absent. */
441
+ type MaybeKeys<M> = {
442
+ [K in keyof M]-?: [Extract<M[K], Off>] extends [never] ? never : M[K] extends Off ? never : K;
443
+ }[keyof M];
444
+ /** The fields a `boolean` entry names, each possibly absent; inert where every entry is literal. */
445
+ type MaybeFields<E, M> = [MaybeKeys<M>] extends [never] ? unknown : Partial<Pick<E, MaybeKeys<M> & keyof E>>;
446
+ /** The entity, less the relations {@link RelatedRows} fills in, so none comes back as declared. */
447
+ type WholeRow<E, Q> = Q extends {
448
+ readonly $populate: infer M;
449
+ } ? Omit<E, keyof M & keyof E> : E;
450
+ /** The populated relations, and the `_count` a query asked for. */
451
+ type RelatedRows<E, Q> = Q extends {
452
+ readonly $populate: infer M;
453
+ } ? PopulatedRelations<E, M, keyof M & keyof E> & CountedRelations<E, Q> : CountedRelations<E, Q>;
454
+ /**
455
+ * Each populated relation as its own query shapes it, mapped over parameters constrained to `keyof E` so each
456
+ * member stays linked to its declaration for a rename. A list is always there, empty where the parent has no
457
+ * children, and so is a `$required` to-one; any other to-one may be absent, since a join can find no row.
458
+ */
459
+ type PopulatedRelations<E, M, K extends keyof E, Present extends keyof E = PresentKeys<E, M, K>, Absent extends keyof E = Exclude<K, Present>> = {
460
+ [P in Present]-?: PopulatedRow<E[P], M[P & keyof M]>;
461
+ } & {
462
+ [P in Absent]: PopulatedRow<E[P], M[P & keyof M]> | undefined;
442
463
  };
443
- /** @internal */
444
- type QueryProjectedRow<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E>> = [S | X] extends [never] ? E : IsUniform<V> extends true ? [PopulatedToMany<E, P>] extends [never] ? Pick<E, ProjectedKeys<E, S, V, X, P> & keyof E> : // A populated to-many is always a list, empty where the parent has no children, so it maps
445
- Pick<E, Exclude<ProjectedKeys<E, S, V, X, P>, PopulatedToMany<E, P>> & keyof E> & {
446
- [K in PopulatedToMany<E, P>]-?: NonNullable<E[K]>;
447
- } : E;
448
- /** The to-many relations a query populated, which come back as lists rather than as optional ones. */
449
- type PopulatedToMany<E, P> = Extract<P, ToManyRelationKey<E>>;
464
+ type PresentKeys<E, M, K extends keyof E> = {
465
+ [P in K]: M[P & keyof M] extends true | 1 | object ? IsMany<E[P]> extends true ? P : M[P & keyof M] extends {
466
+ readonly $required: true;
467
+ } ? P : never : never;
468
+ }[K];
469
+ type PopulatedRow<V, O> = NonNullable<V> extends readonly (infer T)[] ? NonNullable<V> extends unknown[] ? FindRow<T, O>[] : readonly FindRow<T, O>[] : FindRow<NonNullable<V>, O>;
470
+ /** The `_count` a query asked for, an inert intersection member where it asked for none. */
471
+ type CountedRelations<E, Q> = Q extends {
472
+ readonly $count: infer M;
473
+ } ? {
474
+ [K in typeof COUNT_RESULT_KEY]: Tallies<E, OnKeys<M> & keyof E, MaybeKeys<M> & keyof E>;
475
+ } : unknown;
476
+ /**
477
+ * Each tally a count, over parameters constrained to `keyof E` and naming `E[R]`, which is what keeps each key
478
+ * linked to its relation for a rename: a template that never names `E[R]` loses it.
479
+ */
480
+ type Tallies<E, On extends keyof E, Maybe extends keyof E> = {
481
+ [R in On]-?: Tally<E[R]>;
482
+ } & {
483
+ [R in Maybe]?: Tally<E[R]>;
484
+ };
485
+ type Tally<_Relation> = number;
450
486
  /**
451
487
  * A write's options: `returning` projects each row it writes as `$select` projects a read, `{ id: true, createdAt: true }`,
452
488
  * read in the same transaction after the write (before it, for a delete), so they hold what the database filled.
453
489
  */
454
- export type WriteOptions<E, S extends FieldKey<E>, V = true> = {
490
+ export type WriteOptions<E, S extends FieldKey<E> = FieldKey<E>, V = BooleanLike> = {
455
491
  readonly returning?: QuerySelect<E, S, V>;
456
492
  };
457
- /** What a write resolves to: `Plain`, its ids or its count, where it names no `returning` field; else `Read`. */
458
- export type ReturningResult<S, Plain, Read> = [S] extends [never] ? Plain : Read;
493
+ /** What each kind of write resolves to: its ids or its count where it names no `returning` field, else the rows it reads back. */
494
+ export type WriteResults<E, S, V> = [S] extends [never] ? {
495
+ readonly inserted: WrittenId<E> | undefined;
496
+ readonly affected: number;
497
+ readonly affectedMany: number;
498
+ } : {
499
+ readonly inserted: ReturnedRow<E, S, V>;
500
+ readonly affected: ReturnedRow<E, S, V> | undefined;
501
+ readonly affectedMany: ReturnedRow<E, S, V>[];
502
+ };
503
+ /**
504
+ * The row `returning` reads back: its keys, every field but them where it subtracts, and where it mixes both, its
505
+ * positive keys, which a key set cannot tell apart, so each may be absent. `NoInfer`: a write naming no `returning`
506
+ * would otherwise infer `S` from the type its result is assigned to.
507
+ */
508
+ type ReturnedRow<E, S, V> = [V] extends [true | 1] ? Pick<E, NoInfer<S> & keyof E> : [V] extends [false | 0] ? Pick<E, Exclude<FieldKey<E>, NoInfer<S>> & keyof E> : Partial<Pick<E, NoInfer<S> & keyof E>>;
459
509
  /**
460
510
  * result of an update operation, as the driver reports it - which is what `run` hands back, where
461
511
  * there is no entity to name the ids against. The `QueryUpsert*Result` pair is the entity-level shape.
@@ -16,7 +16,7 @@ export const QUERY_CLAUSES = {
16
16
  $skip: { value: 'number', scope: 'relation' },
17
17
  $limit: { value: 'number', scope: 'relation' },
18
18
  $distinct: { value: 'boolean', scope: 'relation' },
19
- // A populated relation's rows keep their declared type, so they have no `_count` for a `$count` to fill.
19
+ // Statement only: tallies are read for the statement's rows, never for a populated relation's.
20
20
  $count: { value: 'object', scope: 'statement' },
21
21
  // A vector search ranks only the statement's rows, so a relation's own query has nothing for it to tune.
22
22
  $candidates: { value: 'number', scope: 'statement' },
@@ -1,8 +1,8 @@
1
1
  import type { FieldKey, FieldKeyOf, RelationKey, RelationTarget } from './entity.js';
2
2
  import type { QueryPager, QuerySelect, QuerySortDirection } from './query.js';
3
3
  import type { QueryWhere, QueryWhereFieldValue } from './queryWhere.js';
4
- import type { ExactlyOne, IsMany, RejectKeys } from './utility.js';
5
- /** The columns `$group` names by a literal `true`, so an uninferred `$group`, its own constraint, names none. */
4
+ import type { ExactlyOne, IsMany } from './utility.js';
5
+ /** The columns `$group` names by a literal `true`, so an open `$group` names none. */
6
6
  type GroupedKeys<G> = {
7
7
  [K in keyof G]: G[K] extends true ? K : never;
8
8
  }[keyof G];
@@ -71,12 +71,6 @@ type QueryAggregateArgMap<E> = Record<'$count', QueryAggregateArg<E>> & Record<T
71
71
  export type QueryAggregateFn<E> = ExactlyOne<QueryAggregateArgMap<E>> & {
72
72
  readonly $where?: QueryWhere<E>;
73
73
  };
74
- /** An aggregate's `$where` naming a key it does not have, refused: a captured `$select` skips the excess-property check. */
75
- type AggregateWhereKeys<E, Fn> = Fn extends {
76
- readonly $where: infer W;
77
- } ? {
78
- readonly $where: RejectKeys<Exclude<keyof W, keyof QueryWhere<E>>>;
79
- } : unknown;
80
74
  /** A single-key `{ [op]: Arg }` shape for each op in `Ops`, matched to infer that op's result or its argument. */
81
75
  type FnWithOp<Ops extends string, Arg = unknown> = {
82
76
  [K in Ops]: {
@@ -98,13 +92,6 @@ export type QueryGroupRef<E, K extends keyof E = FieldKey<E> | RelationKey<E>> =
98
92
  export type QueryGroupMap<E> = {
99
93
  readonly [key: string]: true | QueryGroupRef<E>;
100
94
  };
101
- /**
102
- * A captured `$group` against its schema: a field key takes `true` and keeps its link, any other key is an
103
- * alias for a path. A key switched on that is no field is refused by name, which the intersection alone lets by.
104
- */
105
- type QueryGroupSchema<E, G> = Readonly<QuerySelect<E, FieldKey<E>, true>> & {
106
- readonly [K in Exclude<NamedKeys<G>, FieldKey<E>>]: QueryGroupRef<E>;
107
- } & RejectKeys<Exclude<GroupedKeys<G>, FieldKey<E>>>;
108
95
  /**
109
96
  * The value a path reads: the field at its end as its column holds it, `null` only where that does, since
110
97
  * the path joins the rows it reads. `any` answers `unknown`: TypeScript checks a deferred type by
@@ -132,8 +119,9 @@ type QueryAggregateFnResult<E, Fn> = Fn extends FnWithOp<CountingOp> ? number :
132
119
  type Simplify<T> = {
133
120
  [K in keyof T]: T[K];
134
121
  } & {};
135
- /** An aggregate's row: each grouped column with its entity type, each alias with its path's, each computed one with its aggregate's. */
136
- export type QueryAggregateResult<E, G, A> = Simplify<Pick<E, GroupedKeys<G> & FieldKey<E>> & {
122
+ /** An aggregate's row for the query `Q`: each grouped column with its entity type, each alias with its path's, each computed one with its aggregate's. */
123
+ export type QueryAggregateResult<E, Q> = AggregateRow<E, AggregateGroup<Q>, AggregateSelect<Q>>;
124
+ type AggregateRow<E, G, A> = Simplify<Pick<E, GroupedKeys<G> & FieldKey<E>> & {
137
125
  -readonly [K in Exclude<NamedKeys<G>, FieldKey<E>>]: GroupRefValue<E, G[K]>;
138
126
  } & {
139
127
  -readonly [K in keyof A]: QueryAggregateFnResult<E, A[K]>;
@@ -145,35 +133,61 @@ export type QueryHavingMap = {
145
133
  /**
146
134
  * An aggregate query, apart from `Query` so its row type stays honest:
147
135
  * `aggregate(User, { $group: { status: true }, $select: { n: { $count: '*' } }, $having: { n: { $gt: 5 } } })`.
136
+ * `Q` is the query a read captures: each key of its `$group` and `$select` takes the shape its own kind allows,
137
+ * so a typo'd one fails its excess-property check like any other key. Without it, the columns are open.
148
138
  */
149
- export type QueryAggregate<E, G extends QueryGroupMap<E> = QueryGroupMap<E>, A extends QueryAggMap<E> = QueryAggMap<E>> = {
139
+ export type QueryAggregate<E, Q = never> = [Q] extends [never] ? OpenAggregateQuery<E> : AggregateQuery<E, AggregateGroup<Q>, AggregateSelect<Q>>;
140
+ /**
141
+ * An aggregate query whose columns are open, as one assembled elsewhere is typed and the dialects read it.
142
+ * Written out rather than derived: TypeScript 5.7 compares two generic signatures taking a derived one too deeply.
143
+ */
144
+ type OpenAggregateQuery<E> = {
145
+ readonly $where?: QueryWhere<E>;
146
+ readonly $group?: QueryGroupMap<E>;
147
+ readonly $select?: QueryAggMap<E>;
148
+ readonly $having?: QueryHavingMap;
149
+ readonly $sort?: {
150
+ readonly [column: string]: QuerySortDirection;
151
+ };
152
+ } & QueryPager;
153
+ /** A captured aggregate's shape; open where its columns are, as on an entity keyed by an index signature. */
154
+ type AggregateQuery<E, G, A> = string extends keyof G | keyof A ? OpenAggregateQuery<E> : ClosedAggregateQuery<E, G, A>;
155
+ type ClosedAggregateQuery<E, G, A> = {
150
156
  /**
151
157
  * Row-level filtering, applied before grouping (SQL `WHERE`, MongoDB `$match`).
152
158
  */
153
159
  readonly $where?: QueryWhere<E>;
154
160
  /**
155
- * Columns to group by: `{ status: true }`, or an alias for a to-one relation's field by the path to
156
- * it, `{ orderId: { transaction: { orderId: true } } }`. The captured map meets its schema, so a field
157
- * key keeps its link to the entity property, and a typo matches neither form.
161
+ * Columns to group by: a field switched on, `{ status: true }`, keeping its link to the entity property, or
162
+ * an alias for a to-one relation's field by the path to it, `{ orderId: { transaction: { orderId: true } } }`.
158
163
  */
159
- readonly $group?: G & QueryGroupSchema<E, G>;
164
+ readonly $group?: Readonly<QuerySelect<E, FieldKey<E>, true>> & {
165
+ readonly [K in Exclude<keyof G, FieldKey<E>>]: QueryGroupRef<E>;
166
+ };
160
167
  /**
161
- * The computed columns by alias, the captured map meeting its schema so field keys stay linked. An alias
162
- * repeating a `$group` column is refused, since both would come back under one name.
168
+ * The computed columns by alias. An alias repeating a `$group` column is refused, since both would come back
169
+ * under one name.
163
170
  */
164
- readonly $select?: A & {
165
- readonly [K in keyof A]: QueryAggregateFn<E> & AggregateWhereKeys<E, A[K]>;
166
- } & RejectKeys<NamedKeys<A> & NamedKeys<G>>;
171
+ readonly $select?: {
172
+ readonly [K in keyof A]: K extends keyof G ? never : QueryAggregateFn<E>;
173
+ };
167
174
  /** Filtering after grouping, by a result column, each value typed as that column is. */
168
175
  readonly $having?: {
169
- readonly [K in keyof QueryAggregateResult<E, G, A>]?: QueryWhereFieldValue<QueryAggregateResult<E, G, A>[K]>;
176
+ readonly [K in keyof AggregateRow<E, G, A>]?: QueryWhereFieldValue<AggregateRow<E, G, A>[K]>;
170
177
  };
171
178
  /**
172
179
  * Sort the aggregated results by a grouped column or a computed alias - an aggregate's rows are
173
180
  * its groups, so any other entity field names a value the statement never produced.
174
181
  */
175
182
  readonly $sort?: {
176
- readonly [K in keyof QueryAggregateResult<E, G, A>]?: QuerySortDirection;
183
+ readonly [K in keyof AggregateRow<E, G, A>]?: QuerySortDirection;
177
184
  };
178
185
  } & QueryPager;
186
+ /** The `$group` and `$select` maps of a captured aggregate query, or none where it names none. */
187
+ type AggregateGroup<Q> = Q extends {
188
+ readonly $group?: infer G;
189
+ } ? NonNullable<G> : {};
190
+ type AggregateSelect<Q> = Q extends {
191
+ readonly $select?: infer A;
192
+ } ? NonNullable<A> : {};
179
193
  export {};
@@ -1,16 +1,16 @@
1
- import type { EntityId, EntityWrite, FieldKey, RelationKey, UpdateWrite, WrittenId } from './entity.js';
2
- import type { CursorPage, QueryConflictPaths, QueryFilter, QueryFindResult, QueryKeysetProjected, QueryOneProjected, QueryOptions, QueryPage, QueryProjected, QuerySearch, ReturningResult, WriteOptions } from './query.js';
3
- import type { QueryAggMap, QueryAggregate, QueryAggregateResult, QueryGroupMap } from './queryAggregate.js';
1
+ import type { EntityId, EntityWrite, FieldKey, UpdateWrite } from './entity.js';
2
+ import type { Captured, CursorPage, Query, QueryConflictPaths, QueryFilter, QueryFindResult, QueryKeyset, QueryOne, QueryOptions, QueryPage, QuerySearch, WriteResults, WriteOptions } from './query.js';
3
+ import type { QueryAggregate, QueryAggregateResult } from './queryAggregate.js';
4
4
  import type { BooleanLike, Type } from './utility.js';
5
5
  import type { QuerierCountedResult, QuerierSql, QuerierResult, QuerierTransport } from './wire.js';
6
- /** The query type each projected read takes, keyed by the kind of read. */
7
- export type ProjectedQuery<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E>, Sql> = {
8
- readonly one: QueryOneProjected<E, S, V, X, P, C, Sql>;
9
- readonly many: QueryProjected<E, S, V, X, P, C, Sql>;
10
- readonly page: QueryKeysetProjected<E, S, V, X, P, C, Sql>;
6
+ /** The query each read takes, keyed by the kind of read. */
7
+ export type ReadQueries<E, Sql> = {
8
+ readonly one: QueryOne<E, Sql>;
9
+ readonly many: Query<E, Sql>;
10
+ readonly page: QueryKeyset<E, Sql>;
11
11
  };
12
- /** The result type of each projected read on transport `W`, keyed by the kind of read. */
13
- export type ProjectedResult<W extends QuerierTransport, T> = {
12
+ /** The result type of each read on transport `W`, keyed by the kind of read. */
13
+ export type ReadResults<W extends QuerierTransport, T> = {
14
14
  readonly one: QuerierResult<W, T | undefined>;
15
15
  readonly many: QuerierResult<W, T[]>;
16
16
  readonly counted: QuerierCountedResult<W, T>;
@@ -18,40 +18,39 @@ export type ProjectedResult<W extends QuerierTransport, T> = {
18
18
  readonly stream: AsyncIterable<T>;
19
19
  };
20
20
  /**
21
- * A read that takes an entity and a query, and returns rows narrowed to what the query projected. `Q` picks
22
- * the query type, `R` the result type on transport `W`, and `O` the options. Declaring it once saves every
23
- * such read from repeating the six type parameters.
21
+ * A read that takes the entity first, then the query, and returns rows narrowed to what the query projected. `K` picks
22
+ * the query type, `R` the result type on transport `W`, and `O` the options.
24
23
  */
25
- export type ProjectedRead<Q extends keyof ProjectedQuery<object, never, never, never, never, never, never>, R extends keyof ProjectedResult<QuerierTransport, unknown>, W extends QuerierTransport, O> = <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: ProjectedQuery<E, S, V, X, P, C, QuerierSql<W>>[Q], opts?: O) => ProjectedResult<W, QueryFindResult<E, S, V, X, P, C>>[R];
24
+ export type EntityRead<K extends keyof ReadQueries<object, never>, R extends keyof ReadResults<QuerierTransport, unknown>, W extends QuerierTransport, O> = <E extends object, const Q extends ReadQueries<E, QuerierSql<W>>[K]>(entity: Type<E>, q: Captured<ReadQueries<E, QuerierSql<W>>[K], Q>, opts?: O) => ReadResults<W, QueryFindResult<E, Q>>[R];
26
25
  /**
27
26
  * The operations the server and the browser client declare alike, per transport `W`, options `O`,
28
27
  * and delete options `DO`, which on the client also carry the {@link QueryOptions} it cannot pass otherwise.
29
28
  */
30
29
  export interface SharedQuerier<W extends QuerierTransport, O, DO = O> {
31
30
  /** Find the record with the given primary key. */
32
- 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, QuerierSql<W>>, opts?: O): QuerierResult<W, QueryFindResult<E, S, V, X, P, C> | undefined>;
31
+ findOneById<E extends object, const Q extends QueryOne<E, QuerierSql<W>> = {}>(entity: Type<E>, id: EntityId<E>, q?: Captured<QueryOne<E, QuerierSql<W>>, Q>, opts?: O): QuerierResult<W, QueryFindResult<E, Q> | undefined>;
33
32
  /**
34
33
  * obtains the first record matching the given search parameters.
35
34
  * @param entity the target entity
36
35
  * @param q the criteria options
37
36
  * @return the record
38
37
  */
39
- findOne: ProjectedRead<'one', 'one', W, O>;
38
+ findOne: EntityRead<'one', 'one', W, O>;
40
39
  /**
41
40
  * obtains the records matching the given search parameters.
42
41
  * @param entity the target entity
43
42
  * @param q the criteria options
44
43
  * @return the records
45
44
  */
46
- findMany: ProjectedRead<'many', 'many', W, O>;
45
+ findMany: EntityRead<'many', 'many', W, O>;
47
46
  /** Find the records matching the query, and count every match past its page. */
48
- findManyAndCount: ProjectedRead<'many', 'counted', W, O>;
47
+ findManyAndCount: EntityRead<'many', 'counted', W, O>;
49
48
  /**
50
49
  * Read a page of the records matching the query, from a cursor instead of an offset, so every page costs
51
50
  * the same as the first and rows written in between shift no page. The sort must be total: it must end in
52
51
  * the key or a unique, non-null field. Counts nothing.
53
52
  */
54
- findManyPage: ProjectedRead<'page', 'page', W, O>;
53
+ findManyPage: EntityRead<'page', 'page', W, O>;
55
54
  /** Count the records matching the filter, or those a page of them takes. */
56
55
  count<E extends object>(entity: Type<E>, q?: QueryPage<E, QuerierSql<W>>, opts?: O): QuerierResult<W, number>;
57
56
  /** Whether any record matches: a count capped at one row, so the engine stops at the first match. */
@@ -83,35 +82,35 @@ export interface UniversalQuerier extends SharedQuerier<'server', QueryOptions>
83
82
  * Stream the records matching the query one at a time, each with the relations and counts `findMany`
84
83
  * reads, for bulk reads. `afterLoad` runs on each row as it arrives.
85
84
  */
86
- findManyStream: ProjectedRead<'many', 'stream', 'server', QueryOptions>;
85
+ findManyStream: EntityRead<'many', 'stream', 'server', QueryOptions>;
87
86
  /** Insert a record and resolve to its id, or the row `returning` reads back. See {@link UniversalQuerier.insertMany}. */
88
- insertOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: EntityWrite<E>, opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, WrittenId<E> | undefined, QueryFindResult<E, S, V>>>;
87
+ insertOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: EntityWrite<E>, opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted']>;
89
88
  /**
90
89
  * Insert records in as few statements as the bind limit allows, resolving to their ids in payload order, or
91
90
  * the rows `returning` reads back. Ids are exact everywhere but MySQL, which infers them from its header and
92
91
  * reports `undefined` rather than a guess for a generated key that is not `AUTO_INCREMENT`.
93
92
  */
94
- insertMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: readonly EntityWrite<E>[], opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, (WrittenId<E> | undefined)[], QueryFindResult<E, S, V>[]>>;
93
+ insertMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: readonly EntityWrite<E>[], opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted'][]>;
95
94
  /** Update the record with the given primary key; resolves to the number of affected rows, or the row `returning` reads back. */
96
- updateOneById<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, id: EntityId<E>, payload: UpdateWrite<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<ReturningResult<S, number, QueryFindResult<E, S, V> | undefined>>;
95
+ updateOneById<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, id: EntityId<E>, payload: UpdateWrite<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['affected']>;
97
96
  /** Update the records matching the query; resolves to the number of affected rows, or the rows `returning` reads back. */
98
- updateMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, payload: UpdateWrite<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<ReturningResult<S, number, QueryFindResult<E, S, V>[]>>;
97
+ updateMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, payload: UpdateWrite<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['affectedMany']>;
99
98
  /** Delete, or soft-delete, the record with the given key; resolves to the number of affected rows, or the row as it was. */
100
- deleteOneById<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, id: EntityId<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<ReturningResult<S, number, QueryFindResult<E, S, V> | undefined>>;
99
+ deleteOneById<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, id: EntityId<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['affected']>;
101
100
  /** Delete, or soft-delete, the records matching the query; resolves to the number of affected rows, or the rows as they were. */
102
- deleteMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<ReturningResult<S, number, QueryFindResult<E, S, V>[]>>;
101
+ deleteMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, q: QuerySearch<E>, opts?: QueryOptions & WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['affectedMany']>;
103
102
  /**
104
103
  * Insert or update a record by its conflict paths; resolves to its id, or the row `returning` reads back. A
105
104
  * conflicting row takes the payload less those paths, or `update` as `updateMany` takes one: `{ uses: { $inc: 1 } }`
106
105
  * counts, and `{}` leaves the row as it is. Either branch writes the cascaded relations it is given.
107
106
  */
108
- upsertOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityWrite<E>, update?: UpdateWrite<E>, opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, WrittenId<E> | undefined, QueryFindResult<E, S, V>>>;
107
+ upsertOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: EntityWrite<E>, update?: UpdateWrite<E>, opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted']>;
109
108
  /** Insert or update records by their conflict paths, as `upsertOne` does; resolves to their ids in payload order, or the rows. */
110
- upsertMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: readonly EntityWrite<E>[], update?: UpdateWrite<E>, opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, (WrittenId<E> | undefined)[], QueryFindResult<E, S, V>[]>>;
109
+ upsertMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: readonly EntityWrite<E>[], update?: UpdateWrite<E>, opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted'][]>;
111
110
  /** Insert a record, or upsert one naming its key; resolves to its id, or the row `returning` reads back. */
112
- saveOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: EntityWrite<E>, opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, WrittenId<E> | undefined, QueryFindResult<E, S, V>>>;
111
+ saveOne<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: EntityWrite<E>, opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted']>;
113
112
  /** Insert records, or upsert those naming their key; resolves to their ids in payload order, or the rows. */
114
- saveMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: readonly EntityWrite<E>[], opts?: WriteOptions<E, S, V>): Promise<ReturningResult<S, (WrittenId<E> | undefined)[], QueryFindResult<E, S, V>[]>>;
113
+ saveMany<E extends object, const S extends FieldKey<E> = never, const V extends BooleanLike = true>(entity: Type<E>, payload: readonly EntityWrite<E>[], opts?: WriteOptions<E, S, V>): Promise<WriteResults<E, S, V>['inserted'][]>;
115
114
  /**
116
115
  * Restore soft-deleted records (sets the soft-delete field back to `null`). Throws if the
117
116
  * entity has no soft-delete field.
@@ -124,7 +123,7 @@ export interface UniversalQuerier extends SharedQuerier<'server', QueryOptions>
124
123
  * @param q the aggregate query options
125
124
  * @return the aggregate results
126
125
  */
127
- aggregate<E extends object, const G extends QueryGroupMap<E>, const A extends QueryAggMap<E>>(entity: Type<E>, q: QueryAggregate<E, G, A>, opts?: QueryOptions): Promise<QueryAggregateResult<E, G, A>[]>;
126
+ aggregate<E extends object, const Q extends QueryAggregate<E>>(entity: Type<E>, q: Captured<QueryAggregate<E, Q>, Q>, opts?: QueryOptions): Promise<QueryAggregateResult<E, Q>[]>;
128
127
  /**
129
128
  * The table's row count as the engine's statistics state it, without reading a row: approximate, as
130
129
  * stale as the last `ANALYZE`, and unfiltered, so soft-deleted rows count. SQLite has none and throws.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://uql-orm.dev",
4
4
  "description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
5
5
  "license": "MIT",
6
- "version": "0.103.1",
6
+ "version": "0.104.0",
7
7
  "type": "module",
8
8
  "engines": {
9
9
  "node": ">=22.18"