@bedrockio/model 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -436,12 +436,11 @@ validation which will:
436
436
  - Append the same validation to `Model.getCreateSchema` and
437
437
  `Model.getUpdateSchema` to allow this constraint to trickle down to the API.
438
438
 
439
- > [!WARNING]
440
- > Note that calling `Model.updateOne` will throw an error when a unique field
441
- > exists on any document **including the document being updated**. This is an
442
- > intentional constraint that allows `updateOne` better peformance by not having
443
- > to fetch the ids of the documents being updated in order to exclude them. To
444
- > avoid this call `Document.save` instead.
439
+ > [!WARNING] Note that calling `Model.updateOne` will throw an error when a
440
+ > unique field exists on any document **including the document being updated**.
441
+ > This is an intentional constraint that allows `updateOne` better peformance by
442
+ > not having to fetch the ids of the documents being updated in order to exclude
443
+ > them. To avoid this call `Document.save` instead.
445
444
  >
446
445
  > Note also that calling `Model.updateMany` with a unique field passed will
447
446
  > always throw an error as the result would inherently be non-unique.
@@ -1023,8 +1022,8 @@ deletion. They are defined in the `onDelete` field of the model definition file:
1023
1022
  "clean": {
1024
1023
  "local": "profile",
1025
1024
  "foreign": {
1026
- Shop: "owner"
1027
- },
1025
+ "Shop": "owner"
1026
+ }
1028
1027
  },
1029
1028
  "errorOnReferenced": {
1030
1029
  "except": ["AuditEntry"]
@@ -1081,7 +1080,7 @@ user.delete();
1081
1080
  ```
1082
1081
 
1083
1082
  In this case, "referenced by" means any other model that explicitly uses "User"
1084
- as a `ref` for type `ObjectId`. `errorOnReference` may also be simply `true`,
1083
+ as a `ref` for type `ObjectId`. `errorOnReferenced` may also be simply `true`,
1085
1084
  which will error on any foreign references of any kind.
1086
1085
 
1087
1086
  `only` may be passed instead of `except`, which will only error when the
@@ -1093,9 +1092,8 @@ Models that have delete hooks defined on them will keep a reference of the
1093
1092
  documents that were deleted. Calling `.restore()` on the document will also
1094
1093
  restore these references.
1095
1094
 
1096
- > [!WARNING]
1097
- > Delete hooks are **only** run on a single document (`.delete` or `.restore`).
1098
- > They will not be run when using model methods like `deleteOne` or
1095
+ > [!WARNING] Delete hooks are **only** run on a single document (`.delete` or
1096
+ > `.restore`). They will not be run when using model methods like `deleteOne` or
1099
1097
  > `deleteMany`.
1100
1098
 
1101
1099
  ### Assign
@@ -16,7 +16,9 @@ exports.ImplementationError = ImplementationError;
16
16
  class ReferenceError extends Error {
17
17
  constructor(message, references) {
18
18
  super(message);
19
- this.references = references;
19
+ this.details = {
20
+ references
21
+ };
20
22
  }
21
23
  }
22
24
  exports.ReferenceError = ReferenceError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/errors.js CHANGED
@@ -10,6 +10,8 @@ export class ImplementationError extends Error {
10
10
  export class ReferenceError extends Error {
11
11
  constructor(message, references) {
12
12
  super(message);
13
- this.references = references;
13
+ this.details = {
14
+ references,
15
+ };
14
16
  }
15
17
  }
package/types/errors.d.ts CHANGED
@@ -6,6 +6,8 @@ export class ImplementationError extends Error {
6
6
  }
7
7
  export class ReferenceError extends Error {
8
8
  constructor(message: any, references: any);
9
- references: any;
9
+ details: {
10
+ references: any;
11
+ };
10
12
  }
11
13
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAAA;CAA8C;AAE9C;IACE,uBAGC;IADC,UAAgB;CAEnB;AAED;IACE,2CAGC;IADC,gBAA4B;CAE/B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAAA;CAA8C;AAE9C;IACE,uBAGC;IADC,UAAgB;CAEnB;AAED;IACE,2CAKC;IAHC;;MAEC;CAEJ"}