Bird
0
0

What will the following Lambda function return if the DynamoDB table 'Orders' is empty?

medium📝 query result Q5 of 15
DynamoDB - with Serverless
What will the following Lambda function return if the DynamoDB table 'Orders' is empty? ```javascript const AWS = require('aws-sdk'); const docClient = new AWS.DynamoDB.DocumentClient(); exports.handler = async () => { const params = { TableName: 'Orders' }; const data = await docClient.scan(params).promise(); return data.Items.length; }; ```
Aundefined
Bnull
CAn error is thrown
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand scan on empty table

    Scan returns an object with Items array; if empty table, Items is empty array.
  2. Step 2: Check returned value

    data.Items.length is 0 because no items exist.
  3. Final Answer:

    0 -> Option D
  4. Quick Check:

    Empty table scan length = 0 [OK]
Quick Trick: Scan returns empty Items array if no data [OK]
Common Mistakes:
MISTAKES
  • Expecting null or error on empty scan
  • Confusing undefined with empty array length

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes