Replicates a limited set of DynamoDB behaviors on local JSON data for testing purposes.

This class is intended to replicate essential DynamoDB behaviors, not the actual API!

For example, the query method accepts hashKey & sortOrder as arguments and returns limited record sets with pageKey. It will accept a filter function, but makes no attempt to replicate DynamoDB query syntax.

All methods can be run synchronously, or asynchronously with a normally- distributed delay.

Type Parameters

Constructors

Methods

Constructors

  • Creates a new MockDb instance.

    Type Parameters

    Parameters

    • data: E[]

      Array of data items to query.

    • delayMean: number = 100

      Mean delay in ms. If omitted or undefined, methods will be synchronous.

    • delayStd: number = 20

      Standard deviation of delay in ms. Default is 20.

    Returns MockDb<E, T>

Methods

  • Replicates the functionality of DynamoDB scan/query. Runs asynchronously with a normally-disributed delay.

    Parameters

    • options: QueryOptions<E, T> = {}

      QueryOptions object.

    • delayMean: number = ...

      Mean delay in ms, overrides constructor delayMean.

    • delayStd: number = ...

      Standard deviation of delay in ms, overrides constructor delayStd.

    Returns Promise<QueryReturn<E, T>>

    QueryReturn object Promise.

    Pass hashKey and hashValue to restrict your search to a specific data partition like a DynamoDB query operation. Otherwise, search will be performed across partitions like a DynamoDB scan.

    Pass limit to return a limited record set and pageKey for the next data page.

    Pass sortOrder to sort the result set by specific keys. See SortOrder for more info.

    Pass filter to filter records based on a custom function.

    See the QueryOptions interface for more info on query options.

  • Replicates the functionality of DynamoDB scan/query. Runs synchronously.

    Parameters

    Returns QueryReturn<E, T>

    QueryReturn object.

    Pass hashKey and hashValue to restrict your search to a specific data partition like a DynamoDB query operation. Otherwise, search will be performed across partitions like a DynamoDB scan.

    Pass limit to return a limited record set and pageKey for the next data page.

    Pass sortOrder to sort the result set by a specific set of keys. See SortOrder for more info.

    Pass filter to filter records based on a custom function.

    See the QueryOptions interface for more info on query options.