hexlabsio/dynamo-ts

cannot queryAll with partitionKey from secondary index when is the same as sortKey in global index

Closed this issue · 0 comments

There is a problem with queryAll in such cases:

I have a table with a definition:

export const sortKeyAsIndexPartitionKeyTableDefinition = defineTable(
    {
        hash: 'string',
        text: 'string?',
        obj: { optional: true, object: { abc: 'string', def: 'number?' } },
        arr: { optional: true, array: { object: { ghi: 'number?' } } },
        jkl: 'boolean?',
        mno: 'string | number | undefined',
        pqr: '"xxx" | "yyy" | "123 456"',
    },
    'hash',
    'text',
    { abc: { partitionKey: 'text' } }, // set partitionKey same as global sortKey
);

And I want to:

const result = await sortKeyAsIndexPartitionKeyTableClient
  .index('abc')
  .queryAll({ text: indexIdentifier }, { limit: 1 });

Result:

TypeError: keys[sortKey] is not a function

Expected:

The query should return the proper items