Skip to content

find() has no _type condition when using gsi #199

Answered by mobsense
TTMoon asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  gsi1sk: { type: String, value: 'example#' },

Whereas if you used:

gsi1sk: {type: String, value: 'example#${_type}'}

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.

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mobsense
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
discussion Question or issue being discussed
2 participants
Converted from issue

This discussion was converted from issue #190 on November 17, 2021 00:00.