@tstdl/base 0.93.49 → 0.93.50

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.
@@ -457,9 +457,12 @@ let EntityRepository = class EntityRepository extends Transactional {
457
457
  */
458
458
  async hasByQuery(query) {
459
459
  const sqlQuery = this.convertQuery(query);
460
- const result = await this.session.execute(sql `SELECT EXISTS(SELECT 1 FROM ${this.#table} WHERE ${sqlQuery}) AS exists`);
461
- console.log(result);
462
- throw new Error('handle result');
460
+ const result = await this.session
461
+ .select({ value: sql `1` })
462
+ .from(this.#table)
463
+ .where(sqlQuery)
464
+ .limit(1);
465
+ return result.length > 0;
463
466
  }
464
467
  /**
465
468
  * Checks if all entities with the given IDs exist.
@@ -471,12 +474,8 @@ let EntityRepository = class EntityRepository extends Transactional {
471
474
  if (uniqueIds.length === 0) {
472
475
  return false;
473
476
  }
474
- const result = await this.session
475
- .select({ count: count() })
476
- .from(this.#table)
477
- .where(inArray(this.#table.id, uniqueIds));
478
- const foundCount = result[0]?.count ?? 0;
479
- return foundCount == uniqueIds.length;
477
+ const count = await this.countByQuery(inArray(this.#table.id, uniqueIds));
478
+ return count == uniqueIds.length;
480
479
  }
481
480
  /**
482
481
  * Tries to insert using ON CONFLICT DO NOTHING
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.49",
3
+ "version": "0.93.50",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"