Skip to content

rhdeck/ddb-manager

Repository files navigation

@raydeck/ddb-manager - v3.0.2

@raydeck/ddb-manager - v3.0.2

Index

Classes

Functions

Functions

queryPage

queryPage(__namedParameters: object, lastKey?: string): Promise‹[object[], string | undefined]›

Defined in index.ts:37

Run paginated query on dynamoDB table

Parameters:

__namedParameters: object

Query options

Name Type Default
IndexName string -
Key string -
Limit number 50
TableName string -
Value string | number -
isReversed boolean false

Optional lastKey: string

Specifies where to start query. Undefined returned when no more items found

Returns: Promise‹[object[], string | undefined]›


setDDB

setDDB(newDDB: DocumentClient): void

Defined in index.ts:13

Set new instance of DynamoDB for ddb-manager to use

Parameters:

Name Type Description
newDDB DocumentClient Instance of DynamoDB

Returns: void

@raydeck/ddb-manager - v3.0.2DDBHandler

Class: DDBHandler

Manager to handle CRUD operations on a dynamoDB item

Hierarchy

  • DDBHandler

Index

Constructors

Properties

Methods

Constructors

constructor

+ new DDBHandler(tableName: string, hashKey: string): DDBHandler

Defined in index.ts:102

Parameters:

Name Type Default
tableName string -
hashKey string "id"

Returns: DDBHandler

Properties

Protected _hashKey

_hashKey: string

Defined in index.ts:90

Item partition key name


cachedValues

cachedValues: object

Defined in index.ts:86

Item attributes

Type declaration:

  • [ key: string]: any

exists

exists: boolean = false

Defined in index.ts:98

Flag that indicates whether item saved persistently. If true, item exists in dynamoDB table; if false, item does not exist in dynamoDB table


id

id: object

Defined in index.ts:94

Item primary key

Type declaration:


loaded

loaded: boolean = false

Defined in index.ts:102

Flag that indicates where item data comes from. If true, data was passed via loadFromItem; if false, data was loaded directly from dynamoDB table


Protected tableName

tableName: string

Defined in index.ts:82

DynamoDB table item lives in

Methods

_create

_create(o: object, id: any, options: object): Promise‹this›

Defined in index.ts:317

Create new dynamoDB Item

If item with primary key already exists, that item will be replaced

Parameters:

Name Type Default Description
o object - Shape of item
id any - Items primary key
options object {} Options for dynamoDB put operation

Returns: Promise‹this›


Protected _update

_update(updates: object): Promise‹this›

Defined in index.ts:264

Update attributes

Parameters:

Name Type Description
updates object Object of attribute key/value pairs

Returns: Promise‹this›


delete

delete(key?: string | object): Promise‹void›

Defined in index.ts:388

Delete item

Parameters:

Name Type Description
key? string | object Primary key of item to delete

Returns: Promise‹void›


get

getT›(key: string, def?: T): T | undefined

Defined in index.ts:346

Get attribute

Type parameters:

T

Parameters:

Name Type Description
key string Name of attribute
def? T Default value for attribute

Returns: T | undefined


has

has(key: string): boolean

Defined in index.ts:353

Check if attribute exists

Parameters:

Name Type Description
key string Name of attribute

Returns: boolean


hashKey

hashKey(): string

Defined in index.ts:119

Return partition key name

Returns: string


hashPage

hashPage(hashValue: any, lastValue?: string): Promise‹[object[], string]›

Defined in index.ts:401

Run paginated query against partition key

Parameters:

Name Type Description
hashValue any Value of items partition key
lastValue? string Specifies where to start query. Undefined returned when no more items found

Returns: Promise‹[object[], string]›


indexPage

indexPage(indexName: string, key: string, value: any, lastValue?: string): Promise‹[object[], string]›

Defined in index.ts:418

Run paginated query against global or secondary index

Parameters:

Name Type Description
indexName string Name of global or secondary index
key string Partition (or sort) key to search against
value any Value an items "Key" should have
lastValue? string -

Returns: Promise‹[object[], string]›


load

load(o: any): Promise‹this›

Defined in index.ts:360

Initialize instance from dynamoDB item

Parameters:

Name Type Description
o any Item primary key

Returns: Promise‹this›


loadFromItem

loadFromItem(Item: object): this

Defined in index.ts:378

Initialize instance from a plain old javascript object

Parameters:

Name Type Description
Item object

Returns: this


Protected processRemoves

processRemoves(keys: string[]): string[]

Defined in index.ts:188

Transform an removes object to an array of tuples.

Updates are saved locally only. Item in dynamoDB table will not be updated by this function

Parameters:

Name Type
keys string[]

Returns: string[]


Protected processUpdates

processUpdates(updates: object): [string, any][]

Defined in index.ts:152

Transform an updates object to an array of tuples.

Updates are saved locally only. Item in dynamoDB table will not be updated by this function

Parameters:

Name Type Description
updates object Updates to item attributes

Returns: [string, any][]


remove

remove(key: string): Promise‹void›

Defined in index.ts:134

Remove attribute from a record

Parameters:

Name Type Description
key string Name of attribute

Returns: Promise‹void›


set

set(key: string, value: any): Promise‹void›

Defined in index.ts:127

Set attribute

Parameters:

Name Type Description
key string Name of attribute
value any Value of attribute

Returns: Promise‹void›


setId

setId(id: string | object): void

Defined in index.ts:113

Set id (primary key) of an item

Parameters:

Name Type Description
id string | object Item primary key Id should be an object for a composite primary key

Returns: void


setValues

setValues(mapOfValues: object): Promise‹void›

Defined in index.ts:141

Set multiple attributes

Parameters:

Name Type Description
mapOfValues object Object of attribute key/value pairs (e.g. {attribute1: "value1", attribute2: false})

Returns: Promise‹void›

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published