-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Defining and querying a local index. #439
Comments
@dolsem Sadly I have only really worked with global indexes. I'd recommend checking out the AWS DynamoDB documentation. I also saw this answer that might help you. |
I have the same error and there seems to be a bug in Query.js file. Please check my comment of this page. |
@yokkoyokko You might be right. It was part of PR #344 and issue #343. Any ideas what this should be instead? |
@yokkoyokko is right, @fishcharlie. I've just tested his suggestion in that comment and it works. It also doesn't break any of the existing tests. But that brings another problem: queries don't return any data. If I change my second query to Post.query('author').eq(author).where('createdAt').gt(0), it returns all posts by that author, because every timestamp is obviously greater than 0. But if I change 'createdAt' back to 'updatedAt', no posts get returned. Moreover, scannedCount is always 0. |
I've tested this with an older version of Dynamoose, before PR #344, and it has the same problem: no data gets returned. |
@fishcharlie I'm investigating this issue further. It gets even more strange. The issue is with this line. |
@dolsem Sadly I don't have time to help investigate right now. If you do happen to figure out what is going on feel free to submit a PR and I can take care of that ASAP. @brandongoode, any thoughts here? |
Summary:
I have a schema for posts with timestamps that uses createdAt as the range key and updatedAt as a local index. The idea is to be able to query posts by a particular author by both createdAt and updatedAt.
Code sample:
Schema
General
Current output and behavior:
First query works as expected. Second query fails with:
Expected output and behavior:
Both queries work fine.
Environment:
Operating System: Linux
Operating System Version: 4.15.0-36-generic
Node.js version (
node -v
): v9.11.2NPM version: (
npm -v
): 6.4.1Dynamoose version: 1.0.0
Other information (if applicable):
I've noticed that local index queries in Query tests in Dynamoose look differently. Instead of querying on the hash key of the table first and then specifying local index as the range key, it queries on the local index directly. This would make sense for a global index, but for local? If I understand DynamoDB correctly, local index allows you to choose an alternative range key for the table, while keeping the hash key. So by querying local index I should be able to choose the partition based on the author's name, then display all posts in that partition, sorted by the updatedAt values. Am I missing / not understanding something?
Type (select 1):
Other:
The text was updated successfully, but these errors were encountered: