Interface ObjectAttributeOptions<S>

Options for the @ObjectAttribute decorator. Extends NonNullAttributeOptions with a required schema field describing the object shape.

Object attributes are never nullable. DynamoDB cannot update nested document paths (e.g. address.geo.lat) if the parent object does not exist, which causes: ValidationException: The document path provided in the update expression is invalid for update. To avoid this, @ObjectAttribute fields always exist as at least an empty object {}.

The schema supports all FieldDef types: primitives, enums, nested objects, and arrays. Non-object fields within the schema may still be nullable.

@ObjectAttribute({ alias: "Address", schema: addressSchema })
public readonly address: InferObjectSchema<typeof addressSchema>;
interface ObjectAttributeOptions<S extends ObjectSchema> {
    alias?: string;
    schema: S;
}

Type Parameters

  • S extends ObjectSchema

    The specific ObjectSchema type used for type inference

Hierarchy (View Summary)

Properties

Properties

alias?: string

An optional alias for the attribute as represented in the database table.

This alias is used as the column name in the database table corresponding to the entity. If omitted, the ORM defaults to using the attribute's key as defined within the entity model. Specifying an alias allows for mapping between the entity's attribute names in the code and their respective column names in the database, providing flexibility in naming conventions and supporting scenarios where column names in the database differ from attribute names in the code.

schema: S

The ObjectSchema defining the structure of the object attribute.

Must be declared with as const satisfies ObjectSchema for accurate type inference.