Create an API to get data from your DynamoDB Database

Поделиться
HTML-код
  • Опубликовано: 11 дек 2024

Комментарии • 58

  • @omersaar3864
    @omersaar3864 4 года назад +1

    Hey Sam, just wanted to say I really enjoyed your videos so far. This area of coding is missing some good old fashioned explanations and examples, and you fill the gap perfectly. Looking forward to more content!

    • @CompleteCoding
      @CompleteCoding  4 года назад

      Thanks Omer, glad you're enjoying the content

  • @JeanYvesP
    @JeanYvesP 4 года назад +5

    Thanks Sam! I'm going over all your videos. Really nice!

    • @CompleteCoding
      @CompleteCoding  4 года назад

      Thanks Jean. I'm glad you're finding them useful

  • @shadmanmartinpiyal4057
    @shadmanmartinpiyal4057 3 года назад +3

    I feel I am lucky that I found this playlist.

  • @devprakash5320
    @devprakash5320 3 года назад

    I'm loving this whole series

  • @AmruAshik
    @AmruAshik 4 года назад +3

    for people getting dynamobd.documentclient is not a constructor in the lambda function logs use, var documentClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});

  • @jax_cph
    @jax_cph 3 года назад

    loving you vids Sam.. really eye operning what you can do with serverless + aws
    watching all of your vids now :-)

    • @CompleteCoding
      @CompleteCoding  3 года назад

      Thanks Jax. Serverless is so powerful and flexible.
      There are projects I've down with clients where we build in 3 days a product that would have been months of work without serverless.

  • @vinodsamy
    @vinodsamy 3 года назад

    Splendid Man!! thanks a lot.

  • @olofnuggets5936
    @olofnuggets5936 Год назад

    Can you do more videos like this :)
    can you do a complete Project video that will help allot

  • @Gaurav2964
    @Gaurav2964 4 года назад

    Hi Sam, I am getting the following error:
    `await is only valid in async function `
    The above error is for `const user = await Dynamo.get(ID, tableName).catch(err => {.....`
    Excellent videos. These are really helpful.

    • @Gaurav2964
      @Gaurav2964 4 года назад

      Got it. I didn't declare the handler function in getUser as async. :D

    • @CompleteCoding
      @CompleteCoding  4 года назад

      I've done this so many times. I've now set up vs code snippets to set up new handlers

  • @lfellidev
    @lfellidev 2 года назад +1

    In new serverless version the correct way is:
    iam:
    role:
    statements:
    - Effect: "Allow"
    Action:
    - "dynamodb:*"
    Resource: '*'

    • @CompleteCoding
      @CompleteCoding  2 года назад

      You should still be able to do the method shown with serverless V3.

  • @alexgochenour8740
    @alexgochenour8740 4 года назад +2

    This is really valuable content! Where's your patreon page?

    • @CompleteCoding
      @CompleteCoding  4 года назад +2

      Thanks Alex. I don't have a patreon page but liking and commenting on the videos is a great way to help me out. Checked out your videos too, they're really good and clear. Keep up the great work

  • @AhmedBesbes
    @AhmedBesbes 4 года назад

    Excellent ! thank you!

  • @vivekgupta1590
    @vivekgupta1590 4 года назад

    Hi Sam, I hope you are doing well. In the get response of my lambda call, I get undefined text being returned for those values which are null/empty in DynamoDB. Is there a way for me to ignore/not pass these values as a part of my get response.

    • @CompleteCoding
      @CompleteCoding  4 года назад

      There isn't a way that I know if in Dynamo to do this, but you can easily do it in code.
      Object.entries(data).map(([key, value]) => value === null && delete data[key])
      or you could convert this to a function
      const removeNull = data => {
      Object.entries(data).map(([key, value]) => value === null && delete data[key])
      return data
      }

  • @renejacques8288
    @renejacques8288 2 года назад

    Great video! What if I have an application that interacts w/ dynamodb through lambda, and I get ProvisionedThroughputExceededException when in actuality dynamadb is not producing such error. Any suggestion please?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      That means that your dynamo is probably set to "provisioned capacity" and you're using more than what is set.
      If you've set a read capacity of 1, that's about 2 requests up to 4kb per second. If you try and do a third you'll get that error.
      To fix this either increase the capacity or change the table to be 'on demand'. It costs more but scales super fast and doesn't cost you when you're not using it.

    • @renejacques8288
      @renejacques8288 2 года назад

      @@CompleteCoding I thought about what you said, but the provisioned throughput exceeded exception is not in the Dynamodb log. It's only the application reporting the error erroneously. I wonder if permission issues would cause that.

    • @CompleteCoding
      @CompleteCoding  2 года назад

      @@renejacques8288 I would be surprised if a permissions issue would return that error message.
      googling that error message always says that it's a Dynamo capcity issue.

    • @renejacques8288
      @renejacques8288 2 года назад

      @@CompleteCoding OK. By chance would you know any good study video/material for someone going for the AWS solutions architect and the developer's associate exams?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      @@renejacques8288 Go to Udemy and search for the exam you're taking. There are some with thousands of 5* reviews.
      The ones I've done previously will be out of date now

  • @yenaingoo421
    @yenaingoo421 4 года назад

    Thanks a lot Sir

  • @fleminlouis6861
    @fleminlouis6861 3 года назад

    How to send array of json objects in post method

    • @CompleteCoding
      @CompleteCoding  3 года назад

      First check out my video on creating a POST endpoint ruclips.net/video/AguTaMQGACE/видео.html
      Using that video, you would just need to change the logic in your Lambda. The event body will now be an array of objects so you can do something like:
      const arrayOfNewUsers = JSON.parse(event.body)
      const promiseArray = arrayOfNewUsers.map(async (user) => {
      const newUser = await Dynamo.write(user, tableName)
      return newUser
      });
      const users = await Promise.all(promiseArray);
      If you pass three objects in the array, it will 'map' over them and each one will write to dynamo. You end up with three promises so you just use 'Promise.all' to make sure they all succeed.

  • @cioccari11
    @cioccari11 3 года назад

    is it possible to create this API for using offline (local) with also serverless and dynamodb offline?

    • @CompleteCoding
      @CompleteCoding  3 года назад +1

      Definitely. Here's a video on it
      ruclips.net/video/ul_85jfM0oo/видео.html

    • @cioccari11
      @cioccari11 3 года назад

      @@CompleteCoding thanks for that bro, excellent content. Keep going!

  • @darknights5020
    @darknights5020 2 года назад

    is there a way to fetch the whole table?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      You could use a Scan. This is not advised though as it isn't a very optimised request. You also only get back the first 1MB of data, and then you'd have to subsequently make requests until you've got the whole table.
      The other way is to query each index in your table.
      Either way it's not a process that you want to be doing. Maybe you could redesign your app so you don't have to read a whole table at once.

    • @darknights5020
      @darknights5020 2 года назад

      @@CompleteCoding thank you for the scan option..i also figured out that scan was an option to fetch the whole data contents- if I need to plot in a table..but if i need to plot entity wise or date wise i'll use query thanks for the tips

  • @refririfwan7379
    @refririfwan7379 3 года назад

    I get a response to 502 bad gateway for several times trying. I don't know what happened. I sure the code is the same with this tutorial. Somebody can help me? thanks.

    • @CompleteCoding
      @CompleteCoding  3 года назад

      If you go into the lambda in the AWS console and the 'monitoring' tab. Have a look at the recent invocations. You should be able to see anything that is console.log() in the code. This should point you in the right direction

  • @AyushYadav-mw8pd
    @AyushYadav-mw8pd 2 года назад

    I want the same code for get method but in python

    • @CompleteCoding
      @CompleteCoding  2 года назад

      I've not got any Python code I can share at the moment but this page has a lot of good starter Python code
      docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.03.html

  • @mussabaheenmalik6814
    @mussabaheenmalik6814 4 года назад

    {"message": "Internal server error"} i get this error

    • @CompleteCoding
      @CompleteCoding  4 года назад

      If you look in the lambda logs then you should find out why the function has errored

    • @prabhjotsingh0099
      @prabhjotsingh0099 3 года назад

      I was getting similar error. Looked up Lambda logs and found out my Dynamo.js function was failing because of a typo in AWS.DynamoDB.DocumentClient();