Class: AWS.DynamoDB.DocumentClient
- Inherits:
-
Object
- Object
- AWS.DynamoDB.DocumentClient
- Defined in:
- lib/dynamodb/document_client.js
Overview
The document client simplifies working with items in Amazon DynamoDB by abstracting away the notion of attribute values. This abstraction annotates native JavaScript types supplied as input parameters, as well as converts annotated response data to native JavaScript types.
Marshalling Input and Unmarshalling Response Data
The document client affords developers the use of native JavaScript types
instead of AttributeValue
s to simplify the JavaScript development
experience with Amazon DynamoDB. JavaScript objects passed in as parameters
are marshalled into AttributeValue
shapes required by Amazon DynamoDB.
Responses from DynamoDB are unmarshalled into plain JavaScript objects
by the DocumentClient
. The DocumentClient
, does not accept
AttributeValue
s in favor of native JavaScript types.
JavaScript Type | DynamoDB AttributeValue |
---|---|
String | S |
Number | N |
Boolean | BOOL |
null | NULL |
Array | L |
Object | M |
Buffer, File, Blob, ArrayBuffer, DataView, and JavaScript typed arrays | B |
Support for Sets
The DocumentClient
offers a convenient way to create sets from
JavaScript Arrays. The type of set is inferred from the first element
in the array. DynamoDB supports string, number, and binary sets. To
learn more about supported types see the
Amazon DynamoDB Data Model Documentation
For more information see createSet()
Constructor Summary collapse
-
new AWS.DynamoDB.DocumentClient(options) ⇒ void
constructor
Creates a DynamoDB document client with a set of configuration options.
Method Summary collapse
-
batchGet(params, callback) ⇒ AWS.Request
Returns the attributes of one or more items from one or more tables by delegating to
AWS.DynamoDB.batchGetItem()
. -
batchWrite(params, callback) ⇒ AWS.Request
Puts or deletes multiple items in one or more tables by delegating to
AWS.DynamoDB.batchWriteItem()
. -
createSet(list, options) ⇒ void
Creates a set of elements inferring the type of set from the type of the first element.
-
delete(params, callback) ⇒ AWS.Request
Deletes a single item in a table by primary key by delegating to
AWS.DynamoDB.deleteItem()
. -
get(params, callback) ⇒ AWS.Request
Returns a set of attributes for the item with the given primary key by delegating to
AWS.DynamoDB.getItem()
. -
put(params, callback) ⇒ AWS.Request
Creates a new item, or replaces an old item with a new item by delegating to
AWS.DynamoDB.putItem()
. -
query(params, callback) ⇒ AWS.Request
Directly access items from a table by primary key or a secondary index.
-
scan(params, callback) ⇒ AWS.Request
Returns one or more items and item attributes by accessing every item in a table or a secondary index.
-
transactGet(params, callback) ⇒ AWS.Request
Atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and region.
-
transactWrite(params, callback) ⇒ AWS.Request
Synchronous write operation that groups up to 25 action requests.
-
update(params, callback) ⇒ AWS.Request
Edits an existing item's attributes, or adds a new item to the table if it does not already exist by delegating to
AWS.DynamoDB.updateItem()
.
Constructor Details
new AWS.DynamoDB.DocumentClient(options) ⇒ void
Creates a DynamoDB document client with a set of configuration options.
Method Details
batchGet(params, callback) ⇒ AWS.Request
Returns the attributes of one or more items from one or more tables
by delegating to AWS.DynamoDB.batchGetItem()
.
Supply the same parameters as AWS.DynamoDB.batchGetItem() with
AttributeValue
s substituted by native JavaScript types.
batchWrite(params, callback) ⇒ AWS.Request
Puts or deletes multiple items in one or more tables by delegating
to AWS.DynamoDB.batchWriteItem()
.
Supply the same parameters as AWS.DynamoDB.batchWriteItem() with
AttributeValue
s substituted by native JavaScript types.
createSet(list, options) ⇒ void
Creates a set of elements inferring the type of set from the type of the first element. Amazon DynamoDB currently supports the number sets, string sets, and binary sets. For more information about DynamoDB data types see the documentation on the Amazon DynamoDB Data Model.
delete(params, callback) ⇒ AWS.Request
Deletes a single item in a table by primary key by delegating to
AWS.DynamoDB.deleteItem()
Supply the same parameters as AWS.DynamoDB.deleteItem() with
AttributeValue
s substituted by native JavaScript types.
get(params, callback) ⇒ AWS.Request
Returns a set of attributes for the item with the given primary key
by delegating to AWS.DynamoDB.getItem()
.
Supply the same parameters as AWS.DynamoDB.getItem() with
AttributeValue
s substituted by native JavaScript types.
put(params, callback) ⇒ AWS.Request
Creates a new item, or replaces an old item with a new item by
delegating to AWS.DynamoDB.putItem()
.
Supply the same parameters as AWS.DynamoDB.putItem() with
AttributeValue
s substituted by native JavaScript types.
query(params, callback) ⇒ AWS.Request
Directly access items from a table by primary key or a secondary index.
Supply the same parameters as AWS.DynamoDB.query() with
AttributeValue
s substituted by native JavaScript types.
scan(params, callback) ⇒ AWS.Request
Returns one or more items and item attributes by accessing every item in a table or a secondary index.
Supply the same parameters as AWS.DynamoDB.scan() with
AttributeValue
s substituted by native JavaScript types.
transactGet(params, callback) ⇒ AWS.Request
Atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and region.
Supply the same parameters as AWS.DynamoDB.transactGetItems() with
AttributeValue
s substituted by native JavaScript types.
transactWrite(params, callback) ⇒ AWS.Request
Synchronous write operation that groups up to 25 action requests.
Supply the same parameters as AWS.DynamoDB.transactWriteItems() with
AttributeValue
s substituted by native JavaScript types.
update(params, callback) ⇒ AWS.Request
Edits an existing item's attributes, or adds a new item to the table if
it does not already exist by delegating to AWS.DynamoDB.updateItem()
.
Supply the same parameters as AWS.DynamoDB.updateItem() with
AttributeValue
s substituted by native JavaScript types.