new BaoBaseField()
Base class for all fields. Do not instantiate this class directly.
Methods
(static) BaoBaseField#fromDy(value) → {any}
Convert the field value from the DynamoDB representation to the JS representation.
Name | Type | Description |
---|---|---|
value | any | The value to convert. |
The converted value.
- Type:
- any
(static) BaoBaseField#fromGsi(value) → {any}
Convert the field value from the index format used by DynamoDB to the JS representation.
Name | Type | Description |
---|---|---|
value | any | The value to convert. |
The converted value.
- Type:
- any
(static) BaoBaseField#getInitialValue() → {any}
Get the initial JS value for the field.
The initial value for the field.
- Type:
- any
(static) BaoBaseField#getUpdateExpression(fieldName, value) → {Object}
Get the DynamoDB update expression for the field. You usually don't need to override this. By default, it will return a SET expression, unless the value is null. If the value is null, it will remove the attribute from the item .
Name | Type | Description |
---|---|---|
fieldName | string | The name of the field. |
value | any | The value to update. |
The update expression.
- Type:
- Object
(static) BaoBaseField#toDy(value) → {any}
Convert the field value from the JS representation to DynamoDB representation.
Name | Type | Description |
---|---|---|
value | any | The value to convert. |
The converted value.
- Type:
- any
(static) BaoBaseField#toGsi(value) → {any}
Convert the field value from the JS representation the index format used by DynamoDB. This must be a string representation of the value. Pay special attention to how this value sorts since it will be used for sort keys.
Name | Type | Description |
---|---|---|
value | any | The value to convert. |
The converted value.
- Type:
- any
(static) BaoBaseField#updateBeforeSave(value, currentObject) → {any}
Update the field value before saving. An example of where you might override this is a modified date field that you want to update to the current date/time before saving.
Name | Type | Description |
---|---|---|
value | any | The value to update. |
currentObject | BaoModel | The current model instance. |
The updated value.
- Type:
- any
(static) BaoBaseField#validate(value) → {boolean}
Validate the JS field value.
Name | Type | Description |
---|---|---|
value | any | The value to validate. |
True if the value is valid, otherwise false.
- Type:
- boolean