Function NullableAttribute

  • Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo

    IMPORTANT - For optimal type safety mark the class field property as optional

    Type Parameters

    • T extends default

      The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.

    • K extends NativeScalarAttributeValue

      A type constraint extending Date, ensuring that the decorator is only applied to class fields specifically intended to represent dates.

    Parameters

    • Optional props: AttributeOptions

      An AttributeOptions object providing configuration options for the attribute, such as its alias which allows the attribute to be referred to by an alternative name in the database context. The nullable property is also set to true by default, indicating that the date attribute can be empty.

    Returns ((_value, context) => void)

    A class field decorator function that operates within the class field's context. It configures the field as a date attribute and defines how it should be serialized and deserialized to/from DynamoDB.

    Usage example:

    class MyEntity extends MyTable {
    @NullableAttribute({ alias: 'MyField' })
    public myField?: string; // Set to Optional
    }

    Here, @Attribute decorates myField of MyEntity, marking it as an entity attribute with an alias 'MyField' for ORM purposes.

      • (_value, context): void
      • Parameters

        Returns void

Generated using TypeDoc