Dynamodb plugin to improve schema creation and manipulation, we can use as you can.
A Typescript Node.js package that create schemas on dynamoDb.
First, install the package using npm:
npm install dynamo-schema --save
You will need to import the node module into your file:
import dynamodbSchema from 'dynamodb-schema';
dynamodbSchema.schema([
{
name: 'tableName',
attributtes: [
{ name: 'columnKey', type: 'String' },
{ name: 'column2Key', type: 'String' }
],
keys: [
{ name: 'columnKey', type: 'HASH' },
{ name: 'column2Key', type: 'RANGE' }
],
throughput: {
read: 1,
write: 1
}
}
]);
if you have been loaded informacion schema you only need to execute the following command to create schema.
dynamodbSchema.createSchema();
if you have been loaded informacion schema you only need to execute the following command to drop schema.
dynamodbSchema.dropSchema();
you can set config parameter into dynamodbSchema Object like the following example:
dynamodbSchema.config({
override?: Boolean,
preffix?: String,
subffix?: String,
schema: Array<Schema>,
});
override property could have been used it in order to set into dynamodb-schema object if you want to overried tables if exist or not.
you can use this property to assign schema preffix table, dynamodbSchema joins string before the table name into Schema object.
you can use this property to assign schema subffix table, dynamodbSchema joins string after the table name into Schema object.
you can use this property to assign schema information to the dynamodbSchema object.
Type | Dynamo Type |
---|---|
String | S |
Boolean | S |
Number | Number |
Array | Map |