@squiz/db-lib 1.40.1-alpha.9 → 1.41.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/db-lib",
3
- "version": "1.40.1-alpha.9",
3
+ "version": "1.41.1-alpha.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@aws-sdk/client-secrets-manager": "3.264.0",
30
- "@squiz/dx-common-lib": "1.40.1-alpha.9",
31
- "@squiz/dx-logger-lib": "1.40.1-alpha.9",
30
+ "@squiz/dx-common-lib": "1.41.1-alpha.0",
31
+ "@squiz/dx-logger-lib": "1.41.1-alpha.0",
32
32
  "dotenv": "16.0.3",
33
33
  "pg": "8.9.0"
34
34
  },
35
- "gitHead": "c613b6cf103eb0e484153adecbef5d589bff872b"
35
+ "gitHead": "85be9c5f7ecf79f0037fb6124a122aab38ffaa59"
36
36
  }
@@ -152,11 +152,7 @@ export abstract class AbstractRepository<SHAPE extends object, DATA_CLASS extend
152
152
  }
153
153
  }
154
154
 
155
- protected async executeQuery(
156
- query: string,
157
- values: any[],
158
- transactionClient: PoolClient | null = null,
159
- ): Promise<SHAPE[]> {
155
+ async executeQuery(query: string, values: any[], transactionClient: PoolClient | null = null): Promise<SHAPE[]> {
160
156
  const rows = await this.executeQueryRaw(query, values, transactionClient);
161
157
  return rows.map((a) => this.createAndHydrateModel(a));
162
158
  }
@@ -172,13 +168,14 @@ export abstract class AbstractRepository<SHAPE extends object, DATA_CLASS extend
172
168
  return new this.classRef(inputData);
173
169
  }
174
170
 
175
- async findOne(item: Partial<SHAPE>): Promise<SHAPE | undefined> {
171
+ async findOne(item: Partial<SHAPE>, transactionClient?: PoolClient): Promise<SHAPE | undefined> {
176
172
  const result = await this.executeQuery(
177
173
  `SELECT *
178
174
  FROM ${this.tableName}
179
175
  WHERE ${this.createWhereStringFromPartialModel(item)}
180
176
  LIMIT 1`,
181
177
  Object.values(item),
178
+ transactionClient,
182
179
  );
183
180
 
184
181
  return result[0];