1. 18
    Get all items from a DynamoDB table deployed with CDK using DocumentClient API
    4m 58s

Get all items from a DynamoDB table deployed with CDK using DocumentClient API

InstructorTomasz Łakomy

Share this video with your friends

Send Tweet

Now we're getting somewhere 🎉

Our stack has plenty of resources and how it's the time to start combining them together.

In this lesson we're going to create a new lambda function that will read data from our new TodoTable.

Since we don't want to add unnecessary noise, we're going to define the lambda function in the TodoBackend stack.

After all - whoever will end up using that stack shouldn't have worry too much about the underlying details. That's the power of CDK - we get to abstract away unnecessary implementation details and focusing on solving problems by deploying infrastructure and resources we need to solve them.

ed leach
ed leach
~ 7 months ago

I don't understand the syntax of putting a .promise() at the end of an await. Why not just return the data?

I think adding the .promise() makes the resulting data variable then-able. Is that the only thing it is doing or is there more to it? Thanks.

Tomasz Łakomy
Tomasz Łakomy(instructor)
~ 7 months ago

I don't understand the syntax of putting a .promise() at the end of an await. Why not just return the data?

I think adding the .promise() makes the resulting data variable then-able. Is that the only thing it is doing or is there more to it? Thanks.

Hey!

Sorry for not getting back to you earlier, I didn't touch my laptop this weekend (which I guess is a good thing?)

Anyway! Check out this handy cheatsheet by Nader Dabit:

https://github.com/dabit3/dynamodb-documentclient-cheat-sheet#scan---scanning-and-returning-all-of-the-items-in-the-database

Basically the purpose of putting promise() at the end is like you said - to make it then-able. Otherwise you're not going to get the data but you'll have to provide in the callback to be executed once the response is available.