@guren/orm 1.0.0 → 1.0.1

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/index.d.ts CHANGED
@@ -185,7 +185,7 @@ declare class QueryBuilder<TRecord extends PlainObject = PlainObject, TResult ex
185
185
  /**
186
186
  * Execute the query and return the first matching record, or throw.
187
187
  * @returns The first record
188
- * @throws Error if no record matches
188
+ * @throws ModelNotFoundException (404) if no record matches
189
189
  */
190
190
  firstOrFail(): Promise<TResult>;
191
191
  /**
@@ -1359,7 +1359,7 @@ declare function defineModel<TTable extends TableShape, TBase extends typeof Mod
1359
1359
  }): ModelClassWithTable<TTable, TBase, TCreate>;
1360
1360
 
1361
1361
  /**
1362
- * Exception thrown when a model is not found via findOrFail.
1362
+ * Exception thrown when a model is not found via findOrFail or firstOrFail.
1363
1363
  *
1364
1364
  * Carries a `statusCode` of 404 so that framework exception handlers
1365
1365
  * can render it as a proper HTTP 404 without coupling to the ORM package.
@@ -1368,7 +1368,7 @@ declare class ModelNotFoundException extends Error {
1368
1368
  readonly statusCode = 404;
1369
1369
  readonly modelName: string;
1370
1370
  readonly modelId: unknown;
1371
- constructor(modelName: string, id: unknown, key?: string);
1371
+ constructor(modelName: string, id?: unknown, key?: string);
1372
1372
  }
1373
1373
 
1374
1374
  /**
package/dist/index.js CHANGED
@@ -495,7 +495,7 @@ var ModelNotFoundException = class extends Error {
495
495
  modelName;
496
496
  modelId;
497
497
  constructor(modelName, id, key = "id") {
498
- super(`${modelName} not found for ${key}=${String(id)}`);
498
+ super(id === void 0 ? `${modelName} not found` : `${modelName} not found for ${key}=${String(id)}`);
499
499
  this.name = "ModelNotFoundException";
500
500
  this.modelName = modelName;
501
501
  this.modelId = id;
@@ -708,12 +708,12 @@ var QueryBuilder = class {
708
708
  /**
709
709
  * Execute the query and return the first matching record, or throw.
710
710
  * @returns The first record
711
- * @throws Error if no record matches
711
+ * @throws ModelNotFoundException (404) if no record matches
712
712
  */
713
713
  async firstOrFail() {
714
714
  const record = await this.first();
715
715
  if (record === null) {
716
- throw new Error(`${this.modelClass.name} not found`);
716
+ throw new ModelNotFoundException(this.modelClass.name);
717
717
  }
718
718
  return record;
719
719
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/orm",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {