Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LSI/GSI to EntityManager.findOne() #361

Open
polerin opened this issue Sep 11, 2023 · 1 comment
Open

Add support for LSI/GSI to EntityManager.findOne() #361

polerin opened this issue Sep 11, 2023 · 1 comment

Comments

@polerin
Copy link

polerin commented Sep 11, 2023

Currently EntityManager.find() allows for querying against an LSI/GSI by specifying the desired index in the queryOptions. As getting a single item by LSI is a common use case in our consuming code, it would be much easier if this method supported it.

One potential wrinkle for this request is that findOne() currently requires the primary key, and in this instance the sort key is going to be unknown (hence the index query). findOne() signature might need to be updated to PrimaryKey | PartitionKey based on queryOptions.index !== undefined.

@cckn
Copy link

cckn commented Nov 15, 2023

Typedorm should not support findOne() for LSI/GSI because DynamoDB does not allow single-item retrieval using these indexes. The findOne() method is optimized for primary key queries, and including index support would conflict with DynamoDB's inherent functionality and potentially confuse users.

The GetItem and BatchGetItem operations can't be used on a local secondary index.

The GetItem and BatchGetItem operations can't be used on a global secondary index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants