Skip to content

Type inference for conditional update #487

@ajanim

Description

@ajanim

Looking to run a conditional update based on the existence of a particular attribute. I expect the type of updatedProgress to match the full entity, but the inferred type is an object which only includes SK. The object returned does include all properties (contrary to the type inference).

This version has the correct expected return type.

const { Attributes: updatedProgress } = await ProgressEntity.update(
        {
          PK1,
          PK2,
          SK,
          date,
        },
        {
          conditions: [],
          returnValues: 'ALL_NEW',
        },
      );

This version does not.

const { Attributes: updatedProgress } = await ProgressEntity.update(
        {
          PK1,
          PK2,
          SK,
          date,
        },
        {
          conditions: [
            {
              attr: 'SK',
              exists: true,
            },
          ],
          returnValues: 'ALL_NEW',
        },
      );

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions