0

This is one of the fields of StringSet type that is returned from DynamoDb.

permissions:
       Set {
         wrapperName: 'Set',
         values:
          [ 'BannerConfigReadOnly',
            'CampaignBannerCreate',
            'CampaignPromoCreate',
            'CampaignReadOnly',
            'MasterplanReadOnly',
            'SegmentCreate',
            'SegmentDownload',
            'SegmentUpload' ],
         type: 'String' } 
    }

Now, I am using aws.DynamoDB.Converter.unmarshal function to get it in this format

permissions: ['BannerConfigReadOnly',
            'CampaignBannerCreate',
            'CampaignPromoCreate',
            'CampaignReadOnly',
            'MasterplanReadOnly',
            'SegmentCreate',
            'SegmentDownload',
            'SegmentUpload']

But, this is what i get

{}

Any ideas what, I may be doing wrong.

This is my code

const aws = require('aws-sdk');
const documentClient = new aws.DynamoDB.DocumentClient();
documentClient.scan(params, (err, data) => {
    if (err) {
      reject(err);
    } else {
      let processedItems = [...data.Items];
    var test = aws.DynamoDB.Converter.unmarshall(processedItems[0].permissions);
      console.log(`test is ${JSON.stringify(test)}`);
    }});

ProcessedItems[0] is this

{ email: '[email protected]',
  tenant: 'Canada',
  permissions:
   Set {
     wrapperName: 'Set',
     values:
      [ 'BannerConfigReadOnly',
        'CampaignBannerCreate',
        'CampaignPromoCreate',
        'CampaignReadOnly',],
     type: 'String' } }
2
  • 1
    That data is already unmarshalled since you are using the DocumentClient. Consider just using processedItems[0].permissions.values to get the values of the set. Commented Jul 8, 2019 at 18:53
  • Thank you @cementblocks that worked. Commented Jul 8, 2019 at 19:01

1 Answer 1

1

That data is already unmarshalled since you are using the DocumentClient. Consider just using processedItems[0].permissions.values to get the values of the set.

Sign up to request clarification or add additional context in comments.

1 Comment

I mixed up and didn't realize i had change my code to use DocumentClient that already unmarshalls the DynamoDB response. haha Thank you for pointing that out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.