-
Notifications
You must be signed in to change notification settings - Fork 85
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
Update use Query instead of Scan #506
base: master
Are you sure you want to change the base?
Conversation
pkg/db/db.go
Outdated
} | ||
} | ||
|
||
output, err := db.Client.Scan(scanInput) | ||
output, err := db.Client.Query(queryInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we only do the query if an index field is present, and a scan otherwise?
@@ -628,13 +628,16 @@ func (db *DB) GetLeases(input GetLeasesInput) (GetLeasesOutput, error) { | |||
filters := make([]string, 0) | |||
filterValues := make(map[string]*dynamodb.AttributeValue) | |||
|
|||
queryInput := &dynamodb.QueryInput{ | |||
TableName: aws.String(db.LeaseTableName), | |||
ConsistentRead: aws.Bool(db.ConsistentRead), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work given that no index is given?
I think the easist way to accomplish this is
- Go back to largely how it was
- Make a variable called, queryable, and queryIndex (or something like that) and mark it false to start
- If one of the index filters are set, set the field (make sure not to overwrite, we probably want to prioritize principal_id)
- Make the query with filters if queryable, make the scan with filters otherwise
- Output the results to the same spot
Proposed changes
Types of changes
Checklist
README.md
, inline comments, etc.)CHANGELOG.md
under a## next
release, with a short summary of my changesRelevant Links
Further comments