docs icon indicating copy to clipboard operation
docs copied to clipboard

Cbonif/single-table-design

Open chrisbonifacio opened this issue 1 year ago • 1 comments

Description of changes:

Adds page that goes over single table design in DynamoDB with an Amplify Gen 2 schema example and code snippets

Related GitHub issue #, if available:

Instructions

If this PR should not be merged upon approval for any reason, please submit as a DRAFT

Which product(s) are affected by this PR (if applicable)?

  • [ ] amplify-cli
  • [ ] amplify-ui
  • [ ] amplify-studio
  • [ ] amplify-hosting
  • [ ] amplify-libraries

Which platform(s) are affected by this PR (if applicable)?

  • [ ] JS
  • [ ] Swift
  • [ ] Android
  • [ ] Flutter
  • [ ] React Native

Please add the product(s)/platform(s) affected to the PR title

Checks

  • [ ] Does this PR conform to the styleguide?

  • [ ] Does this PR include filetypes other than markdown or images? Please add or update unit tests accordingly.

  • [ ] Are any files being deleted with this PR? If so, have the needed redirects been created?

  • [ ] Are all links in MDX files using the MDX link syntax rather than HTML link syntax?
    ref: MDX: [link](https://docs.amplify.aws/) HTML: <a href="https://docs.amplify.aws/">link</a>

When this PR is ready to merge, please check the box below

  • [ ] Ready to merge

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

chrisbonifacio avatar May 24 '24 18:05 chrisbonifacio

Past me (1 week ago) would have loved this! I'm not sure if this is an officially supported feature, but I think it would be interesting to learn how to use functions like begins_with, greater_than, and between on the sort key. It works with the "old schema", like this:

export function request(ctx) {
  return {
    version: '2017-02-28',
    operation: 'Query',
    query: {
      expression: 'PK = :PK and begins_with(SK, :SK)',
      expressionValues: util.dynamodb.toMapValues({
        ':PK': ctx.arguments.PK,
        ':SK': ctx.arguments.SK
      }),
    },
  };
}

Thanks for your effort. :)

printSamuel avatar Jun 09 '24 21:06 printSamuel