- Dyno
- client
- Request
- ReadableStream
- RequestSet
- CompleteRequestSet
- putStream
- reduceCapacity
- castIndexesCapacity
- callCostLogger
- requestHandler
- getMethodType
- wrapDocClient
Creates a dyno client. You must provide a table name and the region where the table resides. Where applicable, dyno will use this table as the default in your requests. However you can override this when constructing any individual request.
If you do not explicitly pass credentials when creating a dyno client, the aws-sdk will look for credentials in a variety of places. See the configuration guide for details.
-
optionsobject configuration parametersoptions.tablestring the name of the table to interact with by defaultoptions.regionstring the region in which the default table residesoptions.endpointstring? the dynamodb endpoint urloptions.httpOptionsobject? httpOptions to provide the aws-sdk client. See constructor docs for details.options.accessKeyIdstring? credentials for the client to utilizeoptions.secretAccessKeystring? credentials for the client to utilizeoptions.sessionTokenstring? credentials for the client to utilizeoptions.loggerobject? a writable stream for detailed logging from the aws-sdk. See constructor docs for details.options.maxRetriesnumber? number of times to retry on retryable errors. See constructor docs for details.options.costLoggerfunction? a function that will be called with consumedCapacityoptions.dynoInstanceDyno? a Dyno instance that will share the underlying AWS client with this one
var Dyno = require('dyno');
var dyno = Dyno({
table: 'my-table',
region: 'us-east-1'
});Returns client a dyno client
Provides a dyno client capable of reading from one table and writing to another.
readOptionsobject configuration parameters for the read table.writeOptionsobject configuration parameters for the write table.
Returns dyno a dyno client.
Create a DynamoDB set. When writing records to DynamoDB, arrays are interpretted
as List type attributes. Use this function to utilize a Set instead.
listarray an array of strings, numbers, or buffers to store in DynamoDB as a set
// This record will store the `data` attribute as a `List` in DynamoDB
var asList = {
id: 'my-record',
data: [1, 2, 3]
};
// This record will store the `data` attribute as a `NumberSet` in DynamoDB
var asNumberSet = {
id: 'my-record',
data: Dyno.createSet([1, 2, 3]);
};Returns object a DynamoDB set
Convert a JavaScript object into a wire-formatted string that can be sent to DynamoDB in an HTTP request.
itemobject a JavaScript object representing a DynamoDB record
var item = {
id: 'my-record',
version: 2,
data: new Buffer.from('Hello World!')
};
console.log(Dyno.serialize(item));
// {"id":{"S":"my-record"},"version":{"N":"2"},"data":{"B":"SGVsbG8gV29ybGQh"}}Returns string the serialized representation of the record
Convert a wire-formatted string into a JavaScript object
strstring the serialized representation of a DynamoDB record
var str = '{"id":{"S":"my-record"},"version":{"N":"2"},"data":{"B":"SGVsbG8gV29ybGQh"}}';
console.log(Dyno.deserialize(str));
// {
// id: 'my-record',
// version: 2,
// data: <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64 21>
// }Returns object a JavaScript object representing the record
A dyno client which extends the aws-sdk's DocumentClient.
List the tables available in a given region. Passthrough to DynamoDB.listTables.
paramsobject request parameters. See DynamoDB.listTables for details.callbackfunction? a function to handle the response. See DynamoDB.listTables for details.
Returns Request
Get table information. Passthrough to DynamoDB.describeTable.
paramsobject request parameters. See DynamoDB.describeTable for details.callbackfunction? a function to handle the response. See DynamoDB.describeTable for details.
Returns Request
Perform a batch of get operations. Passthrough to DocumentClient.batchGet.
paramsobject request parameters. See DocumentClient.batchGet for details.callbackfunction? a function to handle the response. See DocumentClient.batchGet for details.
Returns Request
Perform a batch of write operations. Passthrough to DocumentClient.batchWrite.
paramsobject request parameters. See DocumentClient.batchWrite for details.callbackfunction? a function to handle the response. See DocumentClient.batchWrite for details.
Returns Request
Delete a single record. Passthrough to DocumentClient.delete.
paramsobject request parameters. See DocumentClient.delete for details.callbackfunction? a function to handle the response. See DocumentClient.delete for details.
Returns Request
Get a single record. Passthrough to DocumentClient.get.
paramsobject request parameters. See DocumentClient.get for details.callbackfunction? a function to handle the response. See DocumentClient.get for details.
Returns Request
Put a single record. Passthrough to DocumentClient.put.
paramsobject request parameters. See DocumentClient.put for details.callbackfunction? a function to handle the response. See DocumentClient.put for details.
Returns Request
Update a single record. Passthrough to DocumentClient.update.
paramsobject request parameters. See DocumentClient.update for details.callbackfunction? a function to handle the response. See DocumentClient.update for details.
Returns Request
Break a large batch of get operations into a set of requests that can be sent individually or concurrently.
paramsobject unbounded batchGetItem request parameters. See DocumentClient.batchGet for details.
Returns RequestSet
Break a large batch of write operations into a set of requests that can be sent individually or concurrently.
paramsobject unbounded batchWriteItem request parameters. See DocumentClient.batchWrite for details.
Returns RequestSet
Break a large batch of get operations into a set of requests that are intended to be sent concurrently.
paramsobject unbounded batchGetItem request parameters. See DocumentClient.batchGet for details.
Returns CompleteRequestSet
Break a large batch of write operations into a set of requests that are intended to be sent concurrently.
paramsobject unbounded batchWriteItem request parameters. See DocumentClient.batchWrite for details.
Returns CompleteRequestSet
Create a table. Passthrough to DynamoDB.createTable, except the function polls DynamoDB until the table is ready to accept reads and writes, at which point the callback function is called.
paramsobject request parameters. See DynamoDB.createTable for details.callbackfunction? a function to handle the response. See DynamoDB.createTable for details.
Returns Request
Delete a table. Passthrough to DynamoDB.deleteTable, except the function polls DynamoDB until the table is ready to accept reads and writes, at which point the callback function is called.
paramsobject request parameters. See DynamoDB.deleteTable for details.callbackfunction? a function to handle the response. See DynamoDB.deleteTable for details.
Returns Request
Provide the results of a query as a Readable Stream. This function will paginate through query responses, making HTTP requests as the caller reads from the stream.
paramsobject query request parameters. See DocumentClient.query for details.
Returns ReadableStream
Provide the results of a scan as a Readable Stream. This function will paginate through query responses, making HTTP requests as the caller reads from the stream.
paramsobject scan request parameters. See DocumentClient.scan for details.
Returns ReadableStream
Query a table or secondary index. Passthrough to DocumentClient.query.
-
paramsobject request parameters. See DocumentClient.query for details.params.Pagesnumber maximum number of pages of query results to request. Set toInfinityto return all available data. (optional, default1)
-
callbackfunction? a function to handle the response. See DocumentClient.query for details.
Returns any a Request if not paginating, or a ReadableStream if multiple pages were requested
Scan a table or secondary index. Passthrough to DocumentClient.scan.
-
paramsobject request parameters. See DocumentClient.scan for details.params.Pagesnumber maximum number of pages of scan results to request. Set toInfinityto return all available data. (optional, default1)
-
callbackfunction? a function to handle the response. See DocumentClient.scan for details.
Returns any a Request if not paginating, or a ReadableStream if multiple pages were requested
An object representing an aws-sdk request. See aws-sdk's documentation for details
A Node.js Readable Stream. See node.js documentation for details.
This is an objectMode = true stream, where each object emitted is a single
DynamoDB record.
ConsumedCapacityobject once the stream has begun making requests, theConsumedCapacityparameter will report the total capacity consumed by the aggregate of all requests that have completed. This property will only be present if theReturnConsumedCapacityparameter was set on the initial request.
An array of AWS.Requests
Send all the requests in a set, optionally specifying concurrency. The emphasis is on making it transparent to the caller the exact outcome of each request in the set.
The callback function will be passed arguments in this order:
- error: set to null if no errors occurred, otherwise an array of errors with indexes that correspond to the indexes of the original request set
- responses: always an array of responses equal with indexes corresponding
to the original request set. If a particular request encountered an error,
that index in the
responsesarray will be set tonull. - unprocessed: set to null if no unprocessed results were detected, otherwise a new set of requests with its own .sendAll function bound to it. Again, indexes correspond to those in the original request set.
concurrencynumber? the concurrency with which to make requests. Default value is1.callbackfunction a function to handle the response.
An array of AWS.Requests
Send all the requests in a set, optionally specifying concurrency. This function will retry unprocessed items and return a single response body aggregated from results of all the individual requests.
The callback function will be passed a single error object if any occurred, and the aggregated response body. If all requests encountered an error, the second argument will be null. Otherwise the callback may be provided with an error as well as the outcome from successful requests.
concurrencynumber? the concurrency with which to make requests. Default value is1.callbackfunction a function to handle the response.
Creates a Writable stream.
Writing individual records to the stream will aggregate them into sets of
25 items and submit them as BatchWriteItem requests.
-
optionsobject stream options. See Writable stream documentation for available options. The stream will always setobjectMode: truefor you.options.concurrencynumber set the maximum desired concurrency for outgoing BatchWriteItem requests. (optional, default1)options.retryfunction? sets the provided function as a retry event listener on outgoing BatchWriteItem requests.
Returns any a Writable stream
Reduce two sets of consumed capacity metrics into a single object This should be in sync with Callback Parameters section of https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#query-property
existingobject capacity. This object will be updated.incomingnew(object | array) capacity object(s) to be added to the existing object.
Cast CapacityUnits to ReadCapacityUnits or WriteCapacityUnits based on the cast type
indexesObject GlobalSecondaryIndexes or LocalSecondaryIndexes see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ConsumedCapacity.html#DDB-Type-ConsumedCapacity-GlobalSecondaryIndexescastKeystring ReadCapacityUnits | WriteCapacityUnits
Call the costLogger function configured in the options with consumed CapacityUnits
resobject The response of dynamoDB requesttypestring Read | WritecostLoggerfunction configured in the optionsTimenumber the time consumed
Wrap the native method of DynamoDB to call the costLogger in the callback. If no costLogger is provided, just return the native method directly
costLoggerfunction The function that will be called with casted consumedCapacitynativeMethodfunction The native method of dynamoDBtypestring Indicate the method consumes Read or Write capacity
Get if a method is a write or read method
fnNamestring
Returns any Write|Read
Wrap all methods used of DynamoDB DocumentClient with requestHandler