Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all fields present in aws-dynamoDB?

Tags:

I am using Node.js

var AWS = require('aws-sdk');

AWS.config.update({
  region: "region",
  endpoint: "https://dynamodb.region.amazonaws.com"
});
var dynamodb = new AWS.DynamoDB();
    var params = {
      TableName: "acc_new"
    };

    dynamodb.describeTable(params, function(err, data) {
        if (err) console.log(err, err.stack); // an error occurred
       else     console.log(JSON.stringify(data));
    });

Output :

{ AttributeDefinitions: [ { AttributeName: 'Id', AttributeType: 'S' } ],
  TableName: 'acc_new',
  KeySchema: [ { AttributeName: 'Id', KeyType: 'HASH' } ],
  ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } }

output consist of only key schemas(hash and range keys only) associated with the table, Not all the attributes. I want to fetch all attributes associated with data in the table.

Like:

 { AttributeName: 'AccountName', AttributeType: 'S' }
 { AttributeName: 'CreatedBy', AttributeType: 'S' }
 ...
 ...

Is there any way to get descriptions of a dynamoDb table with all of its data fields.

like image 725
Sudhanshu Avatar asked Jul 03 '17 08:07

Sudhanshu


People also ask

How do I get items from DynamoDB table?

To read an item from a DynamoDB table, use the GetItem operation. You must provide the name of the table, along with the primary key of the item you want. The following AWS CLI example shows how to read an item from the ProductCatalog table. With GetItem , you must specify the entire primary key, not just part of it.

Does DynamoDB query return all items?

The Query operation in Amazon DynamoDB finds items based on primary key values. You must provide the name of the partition key attribute and a single value for that attribute. Query returns all items with that partition key value.

How do I get data from AWS DynamoDB?

To export a DynamoDB table, you use the AWS Data Pipeline console to create a new pipeline. The pipeline launches an Amazon EMR cluster to perform the actual export. Amazon EMR reads the data from DynamoDB, and writes the data to an export file in an Amazon S3 bucket.


1 Answers

DynamoDB is a NoSQL database. While creating the table, it doesn't expect all the attributes to be defined in the table. Also, each item can have any number of non-key attributes. Only key attributes are common or mandatory across all the items in the table.

For the above mentioned reasons, the describe table can't provide all the attributes present in the table.

like image 120
notionquest Avatar answered Nov 15 '22 04:11

notionquest