Facade class for easy access to DynamoDB.

Hierarchy

  • DynamoFacade

Constructors

  • Parameters

    • options: DocumentClientOptions = {}

      Options for DocumentClient initialization

    Returns DynamoFacade

Properties

_client: null | DocumentClient = null
options: DocumentClientOptions

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

Accessors

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

    This property is lazily initialized.

    Returns DocumentClient

Methods

  • Returns the attributes of one or more items from one or more tables by delegating to DocumentClient.batchGet().

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

    Example

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

    // 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 batchGet().promise()

    Parameters

    • requestItems: BatchGetRequestMap[]

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

    • Optional options: Partial<BatchGetItemInput>

      The options accepted by the original batchGet method

    Returns Promise<PromiseResult<BatchGetItemOutput, AWSError>>

  • Puts or deletes multiple items in one or more tables by delegating to DocumentClient.batchWrite().

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

    Example

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

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

    Returns

    The same response returned by batchWrite().promise()

    Parameters

    • requestItems: BatchWriteItemRequestMap[]

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

    • Optional options: Partial<BatchWriteItemInput>

      The options accepted by the original batchWrite method

    Returns Promise<PromiseResult<BatchWriteItemOutput, AWSError>>

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

    Returns

    The same response returned by delete().promise()

    Parameters

    • tableName: string

      The name of the table from which to delete the item

    • key: Key

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

    • Optional options: Partial<FacadeUpdateItemInput>

      The options accepted by the original delete method, plus an optional condition field that generates ConditionExpression

    Returns Promise<PromiseResult<DeleteItemOutput, AWSError>>

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

    Returns

    The same response returned by get().promise()

    Parameters

    • tableName: string

      The name of the table containing the requested item

    • key: Key

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

    • Optional options: Partial<GetItemInput>

      The options accepted by the original get method

    Returns Promise<PromiseResult<GetItemOutput, AWSError>>

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

    Returns

    The same response returned by put().promise()

    Parameters

    • tableName: string

      The name of the table to contain the item

    • item: PutItemInputAttributeMap

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

    • Optional options: Partial<FacadePutItemInput>

      The options accepted by the original put method, plus an optional condition field that generates ConditionExpression

    Returns Promise<PromiseResult<PutItemOutput, AWSError>>

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

    Example

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

    Returns

    The same response returned by query().promise()

    Parameters

    • tableName: string

      The name of the table containing the requested items

    • keyCondition: AttributeMap

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

    • Optional options: Partial<FacadeQueryInput>

      The options accepted by the original query method, plus an optional filter field that generates FilterExpression

    Returns Promise<PromiseResult<QueryOutput, AWSError>>

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

    Example

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

    Returns

    The same response returned by scan().promise()

    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

    • filter: AttributeMap

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

    • Optional options: ScanInput

      The options accepted by the original scan method

    Returns Promise<PromiseResult<ScanOutput, AWSError>>

  • Creates a set of elements by delegating to DocumentClient.createSet.

    Returns

    The created DynamoDB Set

    Parameters

    • list: number[] | string[] | binaryType[]

      Collection to represent your DynamoDB Set

    • Optional options: Partial<CreateSetOptions>

      The options accepted by the original createSet method

    Returns DynamoDbSet

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

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

    Example

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

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

    Returns

    The same response returned by transactGet().promise()

    Parameters

    • transactItems: TransactGetItemList

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

    • Optional options: Partial<TransactGetItemsInput>

      The options accepted by the original transactGet method

    Returns Request<TransactGetItemsOutput, AWSError>

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

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

    Example

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

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

    Returns

    The same response returned by transactWrite().promise()

    Parameters

    • transactItems: TransactWriteItemList

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

    • Optional options: Partial<TransactWriteItemsInput>

      The options accepted by the original transactWrite method

    Returns Promise<PromiseResult<TransactWriteItemsOutput, AWSError>>

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

    Returns

    The same response returned by update().promise()

    Parameters

    • tableName: string

      The name of the table containing the item to update

    • key: Key

      The primary key of the item to be updated

    • updatedValues: AttributeMap

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

    • Optional options: Partial<FacadeUpdateItemInput>

      The options accepted by the original update method, plus an optional condition field that generates ConditionExpression

    Returns Promise<PromiseResult<UpdateItemOutput, AWSError>>

Generated using TypeDoc