▸ 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(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.2 › DDBHandler
Manager to handle CRUD operations on a dynamoDB item
- DDBHandler
- _create
- _update
- delete
- get
- has
- hashKey
- hashPage
- indexPage
- load
- loadFromItem
- processRemoves
- processUpdates
- remove
- set
- setId
- setValues
+ new DDBHandler(tableName
: string, hashKey
: string): DDBHandler
Defined in index.ts:102
Parameters:
Name | Type | Default |
---|---|---|
tableName |
string | - |
hashKey |
string | "id" |
Returns: DDBHandler
• _hashKey: string
Defined in index.ts:90
Item partition key name
• cachedValues: object
Defined in index.ts:86
Item attributes
- [ key: string]: any
• 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: object
Defined in index.ts:94
Item primary key
• 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
• tableName: string
Defined in index.ts:82
DynamoDB table item lives in
▸ _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›
▸ _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(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‹T›(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(key
: string): boolean
Defined in index.ts:353
Check if attribute exists
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Name of attribute |
Returns: boolean
▸ hashKey(): string
Defined in index.ts:119
Return partition key name
Returns: string
▸ 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(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(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(Item
: object): this
Defined in index.ts:378
Initialize instance from a plain old javascript object
Parameters:
Name | Type | Description |
---|---|---|
Item |
object |
Returns: this
▸ 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[]
▸ 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(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(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(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(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›