electrodb 1.8.0 → 1.8.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/CHANGELOG.md +5 -1
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/schema.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -166,4 +166,8 @@ All notable changes to this project will be documented in this file. Breaking ch
|
|
|
166
166
|
- Expected typings for the injected v2 client now include methods for `transactWrite` and `transactGet`
|
|
167
167
|
### Changed
|
|
168
168
|
- Map attributes will now always resolve to least an empty object on a `create` and `put` methods (instead of just the root map)
|
|
169
|
-
- In the past, default values for property attributes on maps only resolves when a user provided an object to place the values on. Now default values within maps attributes will now always resolve onto the object on `create` and `put` methods.
|
|
169
|
+
- In the past, default values for property attributes on maps only resolves when a user provided an object to place the values on. Now default values within maps attributes will now always resolve onto the object on `create` and `put` methods.
|
|
170
|
+
|
|
171
|
+
## [1.8.1] - 2022-03-29
|
|
172
|
+
### Fixed
|
|
173
|
+
- Solidifying default application methodology: default values for nested properties will be applied up until an undefined default occurs or default callback returns undefined
|
package/README.md
CHANGED
|
@@ -459,7 +459,7 @@ const EmployeesModel = {
|
|
|
459
459
|
attributes: {
|
|
460
460
|
employee: {
|
|
461
461
|
type: "string",
|
|
462
|
-
default: () =>
|
|
462
|
+
default: () => uuid(),
|
|
463
463
|
},
|
|
464
464
|
firstName: {
|
|
465
465
|
type: "string",
|
|
@@ -686,9 +686,9 @@ attributes: {
|
|
|
686
686
|
Property | Type | Required | Types | Description
|
|
687
687
|
------------ | :--------------------------------------------------------: | :------: | :-------: | -----------
|
|
688
688
|
`type` | `string`, `ReadonlyArray<string>`, `string[]` | yes | all | Accepts the values: `"string"`, `"number"` `"boolean"`, `"map"`, `"list"`, `"set"`, an array of strings representing a finite list of acceptable values: `["option1", "option2", "option3"]`, or `"any"` which disables value type checking on that attribute.
|
|
689
|
-
`required` | `boolean` | no | all | Flag an attribute as required to be present when creating a record. This attribute also acts as a type of `NOT NULL` flag, preventing it from being removed directly.
|
|
689
|
+
`required` | `boolean` | no | all | Flag an attribute as required to be present when creating a record. This attribute also acts as a type of `NOT NULL` flag, preventing it from being removed directly. When applied to nested properties, be mindful that default map values can cause required child attributes to fail validation.
|
|
690
690
|
`hidden` | `boolean` | no | all | Flag an attribute as hidden to remove the property from results before they are returned.
|
|
691
|
-
`default` | `value`, `() => value` | no | all | Either the default value itself or a synchronous function that returns the desired value. Applied before `set` and before `required` check.
|
|
691
|
+
`default` | `value`, `() => value` | no | all | Either the default value itself or a synchronous function that returns the desired value. Applied before `set` and before `required` check. In the case of nested attributes, default values will apply defaults to children attributes until an undefined value is reached
|
|
692
692
|
`validate` | `RegExp`, `(value: any) => void`, `(value: any) => string` | no | all | Either regex or a synchronous callback to return an error string (will result in exception using the string as the error's message), or thrown exception in the event of an error.
|
|
693
693
|
`field` | `string` | no | all | The name of the attribute as it exists in DynamoDB, if named differently in the schema attributes. Defaults to the `AttributeName` as defined in the schema.
|
|
694
694
|
`readOnly` | `boolean` | no | all | Prevents an attribute from being updated after the record has been created. Attributes used in the composition of the table's primary Partition Key and Sort Key are read-only by default. The one exception to `readOnly` is for properties that also use the `watch` property, read [attribute watching](#attribute-watching) for more detail.
|
package/package.json
CHANGED
package/src/schema.js
CHANGED
|
@@ -583,7 +583,7 @@ class MapAttribute extends Attribute {
|
|
|
583
583
|
const valueType = getValueType(data);
|
|
584
584
|
|
|
585
585
|
if (data === undefined) {
|
|
586
|
-
data
|
|
586
|
+
return data;
|
|
587
587
|
} else if (valueType !== "object") {
|
|
588
588
|
throw new e.ElectroAttributeValidationError(this.path, `Invalid value type at entity path: "${this.path}". Expected value to be an object to fulfill attribute type "${this.type}"`);
|
|
589
589
|
}
|