woltsu / tsynamo

Type-friendly TypeScript DynamoDB query builder!
MIT License
31 stars 6 forks source link

Add support for specifying IndexName in queries #34

Open Veikkosuhonen opened 3 months ago

Veikkosuhonen commented 3 months ago

Example:

const cmd = tsynamoClient
      .query("myTable")
      .keyCondition("userId", "=", "123")
      .index("myIndex")
      .compile();

compiles to QueryCommand with "IndexName": "myIndex"

The problem is, need to figure out how to täsä when using a secondary index. Tsynamo would need to know the secondary index partition and sort keys probably. Since only some attributes are projected from the main table to the index, tsynamo needs to know what attributes are available in the index.

Another unknown is if there is a need to differentiate GSI and LSI

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html

Or just yolo and #32 😄

woltsu commented 3 months ago

Thanks for the issue! I will look into the index documentation.