-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Table query #1538
Open
famence
wants to merge
17
commits into
dynamoose:main
Choose a base branch
from
famence:table-query
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Table query #1538
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tributes' values. It's useful when querying a single table with different models with same schema but different default attributes' values (i.e. attribute "type": {"default": "cat"} for the cat model and "type": {"default": "dog"} for the dog model.
This pull request is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days. |
wait for operation to complete before exiting and firing afterEach, which early call could cause a bug — sending the "aws:dynamodb:query:request" to the aws servers
@fishcharlie i just finished the technical part so you are welcome to review the code |
Documentation updated |
Hey, guys! Thanks for the hard work! |
fishcharlie
reviewed
May 7, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Adds the ability to table.query() respecting models correctly. Useful for utilising the single table approach when you want to get multiple items of different models within single request.
⚠️ Preferably to be reviewed after #1517 (depends on #1517) as the current one is based on it.
Code sample:
General
Let's assume we have two models Team and TeamMember within single table:
and some instances of each type:
now we can query the table for any global index (i.e. primary key) and get relevant items with correct models mapping:
The models of each item are identified correctly and all the attributes are mapped as we expect in our schemas.
The magic is in respecting attributes' default values which add +2 score weight and in improved Model.schemaCorrectnessScores method by adding up the scores to determine the most suitable model even if the models' schemas are same except default values.
Type (select 1):
Is this a breaking change? (select 1):
Is this ready to be merged into Dynamoose? (select 1):
Are all the tests currently passing on this PR? (select 1):
Other: