BaoFields. BaoBaseField

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.

Parameters:
NameTypeDescription
valueany

The value to convert.

Returns:

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.

Parameters:
NameTypeDescription
valueany

The value to convert.

Returns:

The converted value.

Type: 
any

(static) BaoBaseField#getInitialValue() → {any}

Get the initial JS value for the field.

Returns:

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 .

Parameters:
NameTypeDescription
fieldNamestring

The name of the field.

valueany

The value to update.

Returns:

The update expression.

Type: 
Object

(static) BaoBaseField#toDy(value) → {any}

Convert the field value from the JS representation to DynamoDB representation.

Parameters:
NameTypeDescription
valueany

The value to convert.

Returns:

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.

Parameters:
NameTypeDescription
valueany

The value to convert.

Returns:

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.

Parameters:
NameTypeDescription
valueany

The value to update.

currentObjectBaoModel

The current model instance.

Returns:

The updated value.

Type: 
any

(static) BaoBaseField#validate(value) → {boolean}

Validate the JS field value.

Parameters:
NameTypeDescription
valueany

The value to validate.

Returns:

True if the value is valid, otherwise false.

Type: 
boolean