DynamoDB Client

ElectroDB supports both the v2 and v3 aws clients. The client can be supplied creating a new Entity or Service, or added to a Entity/Service instance via the setClient() method.

On the instantiation of an Entity:

import { Entity } from 'electrodb';
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
    region: "us-east-1"
});

const task = new Entity({
    // your model
}, {
    client, // <----- client
    table,
});

On the instantiation of an Service:

import { Entity } from 'electrodb';
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
    region: "us-east-1"
});

const task = new Entity({
    // your model
});

const user = new Entity({
    // your model
});

const service = new Service({ task, user }, {
   client, // <----- client
   table,
});

Via the setClient method:

import { Entity } from 'electrodb';
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
    region: "us-east-1"
});

const task = new Entity({
    // your model
});

task.setClient(client);

V2 Client

The v2 sdk will work out of the box with the the DynamoDB DocumentClient.

Example:

import { DocumentClient } from "aws-sdk/clients/dynamodb";
const client = new DocumentClient({
    region: "us-east-1"
});

V3 Client

The v3 client will work out of the box with the the DynamoDBClient.

import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
const client = new DynamoDBClient({
    region: "us-east-1"
});