Skip to main content

Connect to dynamodb Macrometa using mmdynamo

Browser(Javascript) NPM

  1. Install mmdynamo

    npm install mmdynamo --save
  2. Import package

    import { DynamoDB } from "mmdynamo";
  3. Initialize Dynamodb

    import { DynamoDB } from "mmdynamo";

    const dcName = "test.macrometa.io";
    const host = "https://api-" + dcName;
    const apiKey = "xxxxxxxxxxxxxxxxxxxxxx";
    /*
    If you have a JWT token

    const JWT = "xxxxxxxxxxxxxxxxxxxxxx";
    */

    const service = "dynamodb";
    const region = "us-east-1";
    const endpoint = host + "/_api/dynamo";
    // secretAccessKey is a required parameter for aws-sdk we recommend you to pass "c8"
    const secretAccessKey = "c8";
    const accessKeyId = "apikey " + apiKey;
    /*
    If you are using JWT token use the below instead

    const accessKeyId = "bearer " + JWT;
    */

    const client = new DynamoDB({
    region,
    endpoint,
    accessKeyId,
    secretAccessKey,
    });

Browser(Javascrio) as Library

  1. Add mmdynamo

    <script src="https://unpkg.com/mmdynamo@0.2.0/dist/mmdynamo.umd.js"></script>
  2. Initialize Dynamodb

    <script type="text/javascript">
    const dcName = "test.macrometa.io";
    const host = "https://api-" + dcName;
    const apiKey = "xxxxxxxxxxxxxxxxxxxxxx";
    /*
    If you have a JWT token

    const JWT = "xxxxxxxxxxxxxxxxxxxxxx";
    */

    const service = "dynamodb";
    const region = "us-east-1";
    const endpoint = host + "/_api/dynamo";
    // secretAccessKey is a required parameter for aws-sdk we recommend you to pass "c8"
    const secretAccessKey = "c8";
    const accessKeyId = "apikey " + apiKey;
    /*
    If you are using JWT token use the below instead

    const accessKeyId = "bearer " + JWT;
    */
    const { DynamoDB } = window.mmdynamo;

    const client = new DynamoDB({
    region,
    endpoint,
    accessKeyId,
    secretAccessKey,
    });
    </script>

Examples

  1. Create a Table
  2. Create New Item
  3. Read an Item
  4. Update an Item
  5. Delete an Item
  6. Update Table
  7. Delete a Table