Function DateAttribute

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

    Does not allow property to be 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 Date

      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 false by default; the attribute must not 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 {
    @DateAttribute({ alias: 'MyField' })
    public myField: Date;
    }

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

      • (_value, context): void
      • Parameters

        • _value: undefined
        • context: ClassFieldDecoratorContext<T, K>

        Returns void

Generated using TypeDoc