-
ISSUES will not receive priority that do not follow this template or cannot be easily reproduced or diagnosed Describe the bug To Reproduce Table Schema
Model
Code
Log
Expected behavior
Environment (please complete the following information):
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Were you expecting a filter expression to test _type == 'Example'? But that not necessary. If the GSI2PK == 'example#' then that will only match example types. A filter expression on _type is not required and not used. Even if finding with the primary index, a filter expression on _type is not required. |
Beta Was this translation helpful? Give feedback.
-
AWS Example HR-Employee - PK: EmployeeID, SK: Employee Name Both have the same gsi1pk EMPYLOYEE1 If there is no _type expression, EmployeeClient returns Employee and Order both when using gsi1
There is no filter in this expression that filter Employee and Order |
Beta Was this translation helpful? Give feedback.
-
I don't see any 'type' attribute in that table at all. Am I missing something? Some early AWS examples were before thinking evolved on how to do single-table patterns and before the use of a 'type' attribute was seen as best practice. OneTable expects and requires a 'type' attribute. It automatically defines this in the schema behind the scenes so all items have a type. Newer AWS examples by Rick H et al, have a type attribute for items. Now if you are using an existing model, you need to first ensure it has a type attribute and it is set to the name of each model. |
Beta Was this translation helpful? Give feedback.
-
I attached it only to show gsi1pk is the same model. To explain in more detail,
I expected that employclient returns only 1 data that _type is Employee. |
Beta Was this translation helpful? Give feedback.
-
That query will return any items that use that GSI PK which is 'EMPLOYEE1'. So you will get multiple items. Your GSI SK does not discriminate based on type. You use:
Whereas if you used:
that would then return only the employee (provided your data has a _type attribute). Also, typically you should not be providing the GSI PK, but rather be providing the ID and let OneTable calculate the PK value from the value template. |
Beta Was this translation helpful? Give feedback.
-
I'm going to move this to discussions as this is a useful stream for others. |
Beta Was this translation helpful? Give feedback.
That query will return any items that use that GSI PK which is 'EMPLOYEE1'. So you will get multiple items. Your GSI SK does not discriminate based on type. You use:
Whereas if you used:
that would then return only the employee (provided your data has a _type attribute).
Also, typically you should not be providing the GSI PK, but rather be providing the ID and let OneTable calculate the PK value from the value template.