-
-
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
Table query #1538
Conversation
…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! |
I know it's been a little over a year, but just wanted to check: is there still potential for this to be merged? |
@saltman424 This fell off my radar. Do me a favor and try to help remind me this weekend and I'll take a look. This week is pretty busy for me so probably won't get around to it until this weekend. |
@fishcharlie sorry, I meant to ping you earlier in the weekend, but consider this the requested reminder |
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: