dyna-record
    Preparing search index...

    Type Alias AllowNullInWholeValue<T>

    AllowNullInWholeValue: T extends | Date
    | string
    | number
    | boolean
    | null
    | undefined
    | ((...args: unknown[]) => unknown)
        ? T
        : T extends readonly unknown[]
            ? { [I in keyof T]: AllowNullInWholeValue<T[I]> }
            : T extends Record<string, unknown>
                ? {
                    [K in keyof T]: undefined extends T[K]
                        ? AllowNullInWholeValue<NonNullable<T[K]>>
                        | null
                        | undefined
                        : AllowNullInWholeValue<T[K]>
                }
                : T

    A value written whole, as the entity declares it, with null offered on each nullable field at any depth inside it: an object's own fields, a nested object's, an element's of a list within it, and a discriminated union variant's.

    dyna-record stores a nulled field by leaving it out rather than storing DynamoDB's NULL, so null on such a field reads as "not set". That is one rule for every value that is handled whole rather than field by field:

    • an element of a list in an update payload, which is written whole, so the element is stored without the field;
    • a filter or write condition operand compared whole: an equality value, an IN element, and a whole-element $contains operand. The expression builder leaves the field out of the bound value, which then equals a value stored without it, exactly as omitting the field does.

    Nothing else widens. A field that is not nullable stays required and non-null, nothing becomes optional, an object field is never nullable, an element of a list within the value is never null, and neither is the value itself.

    Distributes over a union, so each variant offers null on its own nullable fields. A scalar, a Date and a function pass through unchanged.

    Type Parameters

    • T

      The value's type, as the entity declares it.

    // A line item declared { sku: string; note?: string }
    type LineItemOperand = AllowNullInWholeValue<{ sku: string; note?: string }>;
    // { sku: string; note?: string | null }

    const sameLine: LineItemOperand = { sku: "MUG-1", note: null }; // no note