@tstdl/base 0.92.73 → 0.92.74

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.
@@ -20,7 +20,7 @@ Injector.registerSingleton(Database, {
20
20
  useFactory: (argument, context) => {
21
21
  const connection = argument ?? inject(DatabaseConfig, undefined, { optional: true })?.connection;
22
22
  if (isUndefined(connection)) {
23
- throw new Error('Missing postgres connection. Provide it either via injection argument or provider.');
23
+ throw new Error('Missing postgres connection. Provide it either via injection argument or a provider for DatabaseConfig.');
24
24
  }
25
25
  const pool = new pg.Pool(connection);
26
26
  context.addDisposeHandler(async () => pool.end());
@@ -89,7 +89,7 @@ export declare class EntityRepository<T extends Entity = Entity> implements Reso
89
89
  protected mapManyToInsertColumns(objects: (DeepPartial<T> | NewEntity<T>)[], transformContext: TransformContext): Promise<PgInsertValue<PgTableFromType<string, EntityType>>[]>;
90
90
  protected mapToInsertColumns(obj: DeepPartial<T> | NewEntity<T>, transformContext: TransformContext): Promise<PgInsertValue<PgTableFromType<string, EntityType>>>;
91
91
  protected mapUpdate(update: EntityUpdate<T>, transformContext: TransformContext): Promise<PgUpdateSetSource<PgTableFromType<string, EntityType>>>;
92
- protected getIdLimitQuery(query: Query<T>): import("drizzle-orm/pg-core").WithSubqueryWithSelection<{
92
+ protected getIdLimitQuery(query: Query<T>): Omit<import("drizzle-orm/pg-core").PgSelectBase<string, {
93
93
  id: PgColumn<{
94
94
  name: string;
95
95
  tableName: string;
@@ -107,7 +107,27 @@ export declare class EntityRepository<T extends Entity = Entity> implements Reso
107
107
  identity: undefined;
108
108
  generated: undefined;
109
109
  }, {}, {}>;
110
- }, "id">;
110
+ }, "partial", globalThis.Record<string, "not-null">, false, "where" | "limit", {
111
+ id: string;
112
+ }[], {
113
+ id: PgColumn<{
114
+ name: string;
115
+ tableName: string;
116
+ dataType: "string";
117
+ columnType: "PgUUID";
118
+ data: string;
119
+ driverParam: string;
120
+ notNull: true;
121
+ hasDefault: true;
122
+ isPrimaryKey: true;
123
+ isAutoincrement: false;
124
+ hasRuntimeDefault: false;
125
+ enumValues: undefined;
126
+ baseColumn: never;
127
+ identity: undefined;
128
+ generated: undefined;
129
+ }, {}, {}>;
130
+ }>, "where" | "limit">;
111
131
  protected getAttributesUpdate(attributes: EntityMetadataAttributes | undefined): SQL<unknown> | undefined;
112
132
  protected getTransformContext(): Promise<TransformContext>;
113
133
  }
@@ -268,7 +268,6 @@ let EntityRepository = class EntityRepository {
268
268
  const mappedUpdate = await this.mapUpdate(update, transformContext);
269
269
  const idQuery = this.getIdLimitQuery(query);
270
270
  const [row] = await this.session
271
- .with(idQuery)
272
271
  .update(this.table)
273
272
  .set(mappedUpdate)
274
273
  .where(inArray(this.table.id, idQuery))
@@ -367,7 +366,6 @@ let EntityRepository = class EntityRepository {
367
366
  async hardDeleteByQuery(query) {
368
367
  const idQuery = this.getIdLimitQuery(query);
369
368
  const result = await this.session
370
- .with(idQuery)
371
369
  .delete(this.table)
372
370
  .where(inArray(this.table.id, idQuery));
373
371
  console.log({ deleteResult: result });
@@ -439,10 +437,10 @@ let EntityRepository = class EntityRepository {
439
437
  }
440
438
  getIdLimitQuery(query) {
441
439
  const sqlQuery = this.convertQuery(query);
442
- return this.session.$with('id').as(this.session.select({ id: this.table.id })
440
+ return this.session.select({ id: this.table.id })
443
441
  .from(this.table)
444
442
  .where(sqlQuery)
445
- .limit(1));
443
+ .limit(1);
446
444
  }
447
445
  getAttributesUpdate(attributes) {
448
446
  if (isUndefined(attributes)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.73",
3
+ "version": "0.92.74",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"