DynamoDB: Attribute Not Null (Guide w/ Code Examples)
Provided by Rafal Wilinski
In the AWS JavaScript SDK, you can set an attribute to be not null by including it in the Attribute_definitions
field when creating a table, and setting its nullable
property to false.
Additionally, you can use the update
method to update the attribute and set the NULL
action to NOT_NULL
in the Attribute_updates
field. Below is an example of how to create a table with a non-null attribute:
var AWS = require('aws-sdk'); var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); var params = { AttributeDefinitions: [ { AttributeName: 'example', AttributeType: 'S', }, ], KeySchema: [ { AttributeName: 'example', KeyType: 'HASH', }, ], ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1, }, TableName: 'example_table', }; dynamodb.createTable(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data); } });
Similar Code Examples
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: GetItem
- DynamoDB: Delete Multiple Items in Javascript
- DynamoDB: Not Begins With
- DynamoDB: Query Count
- DynamoDB: Query JSON
- DynamoDB: Increment Counter
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Get By ID
- DynamoDB: Get Query
- DynamoDB: Get All Items
- DynamoDB: Delete Table
- DynamoDB Get in Typescript
- DynamoDB: Bulk Insert
- DynamoDB: Get Unique Values
Login to the AWS Console less. Use Dynobase.
Try 7-day free trial. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase