Facade class for easy access to DynamoDB.

Hierarchy

  • DynamoFacade

Constructors

  • Parameters

    • options: DynamoDBClientConfig = {}

      Options for DynamoDBClient initialization

    Returns DynamoFacade

Properties

_client: null | DynamoDBDocumentClient = null
options: DynamoDBClientConfig

The options used to initialize this object's DynamoDBClient instance.

Accessors

  • get client(): DynamoDBDocumentClient
  • The DynamoDBDocumentClient instance used by the methods of this object.

    This property is lazily initialized.

    Returns DynamoDBDocumentClient

Methods

  • Returns the attributes of one or more items from one or more tables by delegating to BatchGetCommand.

    You can use the batchItem helper to create the request items.

    Example

    import { batchItem as bi } from 'dynamo-facade-v3';

    // These two are equivalent
    df.batchGet([
    bi.get('movies', { actor: 'Tom Hanks', movie: 'Toy Story' }),
    bi.get('movies', { actor: 'Tom Hanks', movie: 'Forrest Gump' }),
    ])

    df.batchGet([
    bi.get('movies', [
    { actor: 'Tom Hanks', movie: 'Toy Story' },
    { actor: 'Tom Hanks', movie: 'Forrest Gump' },
    ])
    ])

    Returns

    The same response returned by send()ing this command

    Parameters

    • requestItems: Record<string, Omit<KeysAndAttributes, "Keys"> & { Keys: undefined | Record<string, any>[] }>[]

      The items to get in the format { [tableName]: { Keys: [...] } }

    • Optional options: Partial<BatchGetCommandInput>

      The options accepted by the original BatchGetCommand class

    Returns Promise<BatchGetCommandOutput>

  • Puts or deletes multiple items in one or more tables by delegating to BatchWriteCommand.

    You can use the batchItem helper to create the request items.

    Example

    import { batchItem as bi } from 'dynamo-facade-v3';

    df.batchWrite([
    bi.put('movies', [
    { actor: 'Tom Hanks', movie: 'Toy Story' },
    { actor: 'Tom Hanks', movie: 'Forrest Gump' },
    ])
    ])

    Returns

    The same response returned by send()ing this command

    Parameters

    • requestItems: Record<string, WriteRequest[]>[]

      The items to write in the format { tableName: [ { ...request }, ...] }

    • Optional options: Partial<BatchWriteCommandInput>

      The options accepted by the original BatchWriteCommand class

    Returns Promise<BatchWriteCommandOutput>

  • Deletes a single item in a table by primary key by delegating to DeleteCommand.

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table from which to delete the item

    • key: Record<string, any>

      A map of attribute names to values, representing the primary key of the item to delete

    • Optional options: Partial<FacadeDeleteItemInput>

      The options accepted by the original DeleteCommand class, plus an optional condition field that generates ConditionExpression

    Returns Promise<DeleteCommandOutput>

  • Returns a set of attributes for the item with the given primary key by delegating to GetCommand.

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table containing the requested item

    • key: Record<string, any>

      A map of attribute names to values, representing the primary key of the item to retrieve

    • Optional options: Partial<GetCommandInput>

      The options accepted by the original GetCommand class

    Returns Promise<GetCommandOutput>

  • Creates a new item, or replaces an old item with a new item by delegating to PutCommand.

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table to contain the item

    • item: Record<string, any>

      A map of attribute name/value pairs, one for each attribute

    • Optional options: Partial<FacadePutItemInput>

      The options accepted by the original PutCommand class, plus an optional condition field that generates ConditionExpression

    Returns Promise<PutCommandOutput>

  • Directly access items from a table by primary key or a secondary index by delegating to QueryCommand.

    Example

    df.query('movies', { actor: 'Tom Hanks', movie: 'Toy Story' })
    

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table containing the requested items

    • keyCondition: Filter

      An object describing the comparisons used to generate KeyConditionExpression, ExpressionAttributeNames, and ExpressionAttributeValues

    • Optional options: Partial<FacadeQueryInput>

      The options accepted by the original QueryCommand class, plus an optional filter field that generates FilterExpression

    Returns Promise<QueryCommandOutput>

  • Repeatedly call query until all paginated results are returned.

    Returns

    A response object with the same fields of the query response as arrays (one item for each request made)

    Parameters

    • tableName: string

      The name of the table containing the requested items

    • keyCondition: Filter

      An object describing the comparisons used to generate KeyConditionExpression, ExpressionAttributeNames, and ExpressionAttributeValues

    • Optional options: Partial<FacadeQueryInput>

      The options accepted by the original QueryCommand class, plus an optional filter field that generates FilterExpression

    Returns Promise<MultiQueryOutput>

  • Returns one or more items and item attributes by accessing every item in a table or a secondary index by delegating to ScanCommand.

    Example

    df.scan('movies', { actor: 'Tom Hanks' })
    

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table containing the requested items; or, if you provide IndexName in the options, the name of the table to which that index belongs

    • Optional filter: Filter

      An object describing the comparisons used to generate FilterExpression, ExpressionAttributeNames, and ExpressionAttributeValues

    • Optional options: Partial<ScanCommandInput>

      The options accepted by the original ScanCommand method

    Returns Promise<ScanCommandOutput>

  • Repeatedly call scan until all paginated results are returned.

    Returns

    A response object with the same fields of the scan response as arrays (one item for each request made)

    Parameters

    • tableName: string

      The name of the table containing the requested items; or, if you provide IndexName in the options, the name of the table to which that index belongs

    • Optional filter: Filter

      An object describing the comparisons used to generate FilterExpression, ExpressionAttributeNames, and ExpressionAttributeValues

    • Optional options: Partial<ScanCommandInput>

      The options accepted by the original ScanCommand method

    Returns Promise<MultiScanOutput>

  • Atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and region by delegating to TransactGetCommand.

    You can use the transactItem helper to create the request items.

    Example

    import { transactItem as tr } from 'dynamo-facade-v3';

    df.transactGet([
    tr.get('movies', { actor: 'Tom Hanks', movie: 'Toy Story' }
    ])

    Returns

    The same response returned by send()ing this command

    Parameters

    • transactItems: (Omit<TransactGetItem, "Get"> & { Get: undefined | Omit<Get, "Key"> & { Key: undefined | Record<string, any> } })[]

      The items to get in the format [{ Get: { TableName: ..., Key: ... } }, ...]

    • Optional options: Partial<TransactGetCommandInput>

      The options accepted by the original TransactGetCommand class

    Returns Promise<TransactGetCommandOutput>

  • Synchronous write operation that groups up to 25 action requests by delegating to TransactWriteCommand.

    You can use the transactItem helper to create the request items.

    Example

    import { transactItem as tr } from 'dynamo-facade-v3';

    df.transactWrite([
    tr.put('movies', { actor: 'Tom Hanks', movie: 'Toy Story' }
    ])

    Returns

    The same response returned by send()ing this command

    Parameters

    • transactItems: (Omit<TransactWriteItem, "ConditionCheck" | "Put" | "Delete" | "Update"> & { ConditionCheck?: Omit<ConditionCheck, "Key" | "ExpressionAttributeValues"> & { ExpressionAttributeValues?: Record<string, any>; Key: undefined | Record<string, any> }; Delete?: Omit<Delete, "Key" | "ExpressionAttributeValues"> & { ExpressionAttributeValues?: Record<string, any>; Key: undefined | Record<string, any> }; Put?: Omit<Put, "Item" | "ExpressionAttributeValues"> & { ExpressionAttributeValues?: Record<string, any>; Item: undefined | Record<string, any> }; Update?: Omit<Update, "Key" | "ExpressionAttributeValues"> & { ExpressionAttributeValues?: Record<string, any>; Key: undefined | Record<string, any> } })[]

      The items to write in the format [ { Put: { ... } }, ...]

    • Optional options: Partial<TransactWriteCommandInput>

      The options accepted by the original TransactWriteCommand class

    Returns Promise<TransactWriteCommandOutput>

  • Edits an existing item's attributes, or adds a new item to the table if it does not already exist by delegating to UpdateCommand.

    Returns

    The same response returned by send()ing this command

    Parameters

    • tableName: string

      The name of the table containing the item to update

    • key: Record<string, any>

      The primary key of the item to be updated

    • updatedValues: Record<string, any>

      A map of attribute name/value pairs with the attributes that must be modified

    • Optional options: Partial<FacadeUpdateItemInput>

      The options accepted by the original UpdateCommand class, plus an optional condition field that generates ConditionExpression

    Returns Promise<UpdateCommandOutput>

Generated using TypeDoc