How to Query your DynamoDB tables with Serverless

แชร์
ฝัง

ความคิดเห็น • 28

  • @PeteWhelan
    @PeteWhelan 3 ปีที่แล้ว

    Thanks Sam . Managed to use this to make queries of multiple indexes across multiple tables.

  • @vinodsamy1725
    @vinodsamy1725 3 ปีที่แล้ว

    now i'm tempted to watch all your videos. Great thanks:))

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว +1

      There are a lot of them now. I'd start by looking for the ones that you could use soon.

  • @shadmanmartinpiyal4057
    @shadmanmartinpiyal4057 3 ปีที่แล้ว

    Great Video!!

  • @amrmonzir
    @amrmonzir 3 ปีที่แล้ว +1

    Thanks for the great video!
    Can you share what KeyConditionExpression can be used to query a GSI and a sort key? Or is that an invalid operation?

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว +1

      Yes you can! Your params would be something like this, where operation is something like "", "="
      const params = {
      TableName: tableName,
      IndexName: index,
      KeyConditionExpression: `${primaryKey} = :primarykey and ${sortKey} ${operation} :sortKey `,
      ExpressionAttributeValues: {
      ':primarykey': primaryKeyValue,
      ':sortkey': sortValue
      },
      };
      docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions

    • @amrmonzir
      @amrmonzir 3 ปีที่แล้ว +1

      @@CompleteCoding thank you so much!

  • @AmruAshik
    @AmruAshik 3 ปีที่แล้ว

    thanks alott man!!

  • @rajatmasih3706
    @rajatmasih3706 3 ปีที่แล้ว

    Good job

  • @afiqagaming6290
    @afiqagaming6290 3 ปีที่แล้ว

    Hi Sam, I am new in serverless. I have a question, If we have set up the database like LSI, GSI in dynamoDB directly, Do we need to set up in yml file also?

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว

      No, you can query a database that you made in the console with serverless. You just need to use the correct table name and it will work the same.
      Setting it up in Serverless means you could copy everything to another account without having to do anything manually.

  • @Clemenstigator
    @Clemenstigator 3 ปีที่แล้ว

    what is the difference in the implementation of global secondary indexes and a local secondary index in serverless?

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว

      local secondary indexes are a very complex topic and there are specific limitations to them. The main one being that you can only create them when you create the table and can't add more in the future. There are also limitations around data size and that you can only query one primary key at once.
      To implement them in serverless would be very similar to creating a table with global secondary indexes. Just change the "GlobalSecondaryIndexes" in your serverless.yml resources to LocallSecondaryIndexes. The structure should be the same

  • @abnergrajales4225
    @abnergrajales4225 3 ปีที่แล้ว

    Very good video, one question ...
    How could dynamodb queries be used to search by latitude and longitude distances? I would appreciate any information. thanks

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว +1

      Querying on multiple fields at the same time isn't something that is easy in Dynamo.
      What you can do is query on one field and then use a query filter on the other field to get the final results that you want.

  • @vivekgupta1590
    @vivekgupta1590 3 ปีที่แล้ว

    Hi Sam, I hope you are doing well. I'm trying to make use of the property ScanForwardIndex which is set to false inorder to display the values in descending order. But I guess I'm not setting the property correctly because I keep on getting the error;
    Serverless Error ---------------------------------------
    An error occurred: MyDynamoDbTable - Encountered unsupported property ScanIndexForward.
    My serverless yml looks something like this;
    Resources:
    MyDynamoDbTable:
    Type: AWS::DynamoDB::Table
    Properties:
    TableName: ${self:custom.tableName}
    AttributeDefinitions:
    - AttributeName: ID
    AttributeType: S
    AttributeName
    AttributeType: S
    KeySchema:
    - AttributeName: ID
    KeyType: HASH
    BillingMode: PAY_PER_REQUEST
    GlobalSecondaryIndexes:
    - IndexName:
    KeySchema:
    - AttributeName:
    KeyType: HASH
    Projection:
    ProjectionType: ALL
    ScanIndexForward: false
    Any tips on how I can resolve this issue?

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว

      The ScanIndexForward value is used as part of a query request to the database, not on the configuration for the database. If you set it to false then the query response data will be ordered in reverse order.
      docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-ScanIndexForward

  • @gunjanmukherjee4076
    @gunjanmukherjee4076 3 ปีที่แล้ว

    Thank you. How can i update a endpoint after deploy it. For example in place of {filename} i write {ID} and deploy it. when i try convert it into {filename} it is throwing Error.

    • @CompleteCoding
      @CompleteCoding  3 ปีที่แล้ว

      What is the error that it's throwing?

    • @gunjanmukherjee4076
      @gunjanmukherjee4076 3 ปีที่แล้ว

      @@CompleteCoding A sibling ({ID}) of this resource already has a variable path part -- only one is allowed (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 146b2a96-0977-436c-9c9f-416357af77e7; Proxy: null).

  • @bestoos2099
    @bestoos2099 4 ปีที่แล้ว +1

    sir please upload a video on authorizers and authentication

    • @CompleteCoding
      @CompleteCoding  4 ปีที่แล้ว +2

      I've had quite a few suggestions to do that so you should see a video on that coming out soon