Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dyno

Package Overview
Dependencies
Maintainers
30
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dyno - npm Package Compare versions

Comparing version 0.7.4 to 0.8.0

bin/cli.js

1

index.js

@@ -12,3 +12,4 @@ var _ = require('underscore');

_(dyno).extend(require('./lib/batch')(config));
_(dyno).extend(require('./lib/describe')(config));
return dyno;
};

45

lib/dynamoRequest.js

@@ -12,5 +12,10 @@ var types = require('./types');

'batchGetItem',
'batchWriteItem'
'batchWriteItem',
'describeTable'
];
var noItems = [
'describeTable'
];
module.exports = function(config) {

@@ -31,2 +36,4 @@ return function(type, parameters, opts, callback) {

var read = false;
var status = true;
var currentKey;

@@ -36,4 +43,5 @@ var readable = new stream.Readable({objectMode:true});

read = true;
while (items.length > 0) {
readable.push(items.shift());
if (!status) {
status=true;
streamRequest();
}

@@ -54,3 +62,12 @@ };

function streamRequest() {
while (status && items.length > 0) {
status = readable.push(items.shift());
}
if (status && currentKey && page < opts.pages) return request(currentKey);
if (items.length === 0 || (!currentKey && page >= opts.pages)) readable.push(null);
}
function request(start) {
currentKey = false;
var attempts = 0;

@@ -95,5 +112,10 @@ if (start) params.ExclusiveStartKey = start;

resp.Items = resp.Items ? types.typesFromDynamo(resp.Items) : [];
items = items.concat(resp.Items);
if (type.indexOf(noItems) === -1) {
resp.Items = resp.Items ? types.typesFromDynamo(resp.Items) : [];
items = items.concat(resp.Items);
} else {
items = resp;
}
var meta = {};

@@ -104,12 +126,11 @@ if (resp.ConsumedCapacity) meta.capacity = resp.ConsumedCapacity;

while (read && items.length > 0) {
readable.push(items.shift());
page++;
currentKey = resp.LastEvaluatedKey;
if (!read && page < opts.pages && currentKey) {
return request(currentKey);
} else if (read) {
return streamRequest();
}
page++;
if (page < opts.pages && resp.LastEvaluatedKey)
return request(resp.LastEvaluatedKey);
if (read) readable.push(null);
if (callback) callback(null, items, metas);

@@ -116,0 +137,0 @@ }

{
"name": "dyno",
"version": "0.7.4",
"version": "0.8.0",
"description": "Simple DynamoDB client",

@@ -9,2 +9,5 @@ "main": "index.js",

},
"bin": {
"dyno": "./bin/cli.js"
},
"author": "Mick Thompson <mick@mick.im>",

@@ -16,2 +19,3 @@ "license": "MIT",

"event-stream": "^3.1.5",
"minimist": "^1.1.0",
"queue-async": "~1.0.7",

@@ -21,3 +25,3 @@ "underscore": "1.6.0"

"devDependencies": {
"dynalite": "https://github.com/mick/dynalite/archive/queryfilters.tar.gz",
"dynalite": "git+https://github.com/mick/dynalite.git#queryFilters",
"seedrandom": "^2.3.6",

@@ -24,0 +28,0 @@ "tap": "^0.4.11"

@@ -34,6 +34,90 @@ ## Dyno

#### CLI
Dyno includes a cli for working with DynamoDB tables.
##### Setup
Dyno assumes that credentials for AWS will be provided in the ENVIRONMENT as [described in the aws-sdk docs](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Environment_Variables)
##### Common flags:
```
dyno <region> <sub command> -e <Endpoint URL>
dyno us-east-1 tables
dyno local tables
// setting the region to local, will set the endpoint to http://localhost:4567
```
##### List tables:
```
dyno local tables
{"TableNames":['my-table', 'my-other-table']}
```
##### Describe a table:
```
dyno local table my-table
{"Table":{"AttributeDefinitions":[{"AttributeName":"collection","AttributeType":"S"},....]}}
```
##### Scan a table:
Outputs line delimited JSON for every item in the table.
```
dyno local scan my-table
{"id":"0.9410678697749972","collection":"somethign:0","attr":"moredata 64"}
{"id":"0.9417226337827742","collection":"somethign:0","attr":"moredata 24"}
{"id":"0.9447696127463132","collection":"somethign:0","attr":"moredata 48"}
{"id":"0.9472108569461852","collection":"somethign:0","attr":"moredata 84"}
....
```
##### Export a table:
Outputs the table schema then does a scan (like above)
```
dyno local export my-table
{"AttributeDefinitions":[{"AttributeName":"collection","AttributeType":"S"},...]}
{"id":"0.9410678697749972","collection":"somethign:0","attr":"moredata 64"}
{"id":"0.9417226337827742","collection":"somethign:0","attr":"moredata 24"}
{"id":"0.9447696127463132","collection":"somethign:0","attr":"moredata 48"}
{"id":"0.9472108569461852","collection":"somethign:0","attr":"moredata 84"}
....
```
##### Import a table:
Receives an exported table on stdin. Expects the first line to be the table schema, and
the rest of the lines to be items.
```
dyno us-west-1 export my-table | dyno local import my-table-copy
```
#### JS api:
##### Setup
```
var dyno = module.exports.dyno = require('dyno')({

@@ -117,3 +201,3 @@ accessKeyId: 'XXX',

This key can be passed back in to another query to get the next page of
This key can be passed back in to another query to get the next page of
results.

@@ -126,2 +210,1 @@

```

@@ -162,6 +162,7 @@ var s = require('./setup')();

test('setup items', function(t) {
var item = {id: 'yo', range: 5};
var item = {id: 'yo', range: 5, blob: new Buffer(300000)};
dyno.putItem(item, itemResp);
function itemResp(err, resp) {
t.equal(err, null, 'no errors')
if(item.range > 7) return t.end();

@@ -176,6 +177,6 @@ item.range+=1;

dyno.scan().pipe(es.writeArray(function(err, data){
t.equal(err, null);
t.equal(data.length, 4);
t.deepEqual(data[0], {id: 'yo', range:5});
t.deepEqual(data[3], {id: 'yo', range:8});
t.equal(err, null, 'no errors');
t.equal(data.length, 4, 'right number of items');
t.deepEqual(_(data[0]).omit('blob'), {id: 'yo', range:5}, 'first item');
t.deepEqual(_(data[3]).omit('blob'), {id: 'yo', range:8}, 'last item');
t.end();

@@ -192,4 +193,4 @@ }));

t.equal(items.length, 4);
t.deepEqual(items[0], {id: 'yo', range:5});
t.deepEqual(items[3], {id: 'yo', range:8});
t.deepEqual(_(items[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(items[3]).omit('blob'), {id: 'yo', range:8});
t.end();

@@ -206,4 +207,4 @@ }

t.equal(items.length, 2);
t.deepEqual(items[0], {id: 'yo', range:5});
t.deepEqual(items[1], {id: 'yo', range:6});
t.deepEqual(_(items[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(items[1]).omit('blob'), {id: 'yo', range:6});
t.end();

@@ -220,4 +221,4 @@ }

t.equal(data.length, 4);
t.deepEqual(data[0], {id: 'yo', range:5});
t.deepEqual(data[3], {id: 'yo', range:8});
t.deepEqual(_(data[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(data[3]).omit('blob'), {id: 'yo', range:8});
t.end();

@@ -234,4 +235,4 @@ }));

t.equal(data.length, 4);
t.deepEqual(data[0], {id: 'yo', range:5});
t.deepEqual(data[3], {id: 'yo', range:8});
t.deepEqual(_(data[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(data[3]).omit('blob'), {id: 'yo', range:8});
t.end();

@@ -247,4 +248,4 @@ }));

t.equal(data.length, 2);
t.deepEqual(data[0], {id: 'yo', range:5});
t.deepEqual(data[1], {id: 'yo', range:6});
t.deepEqual(_(data[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(data[1]).omit('blob'), {id: 'yo', range:6});
t.end();

@@ -261,4 +262,4 @@ }));

t.equal(items.length, 4);
t.deepEqual(items[0], {id: 'yo', range:5});
t.deepEqual(items[3], {id: 'yo', range:8});
t.deepEqual(_(items[0]).omit('blob'), {id: 'yo', range:5});
t.deepEqual(_(items[3]).omit('blob'), {id: 'yo', range:8});
t.end();

@@ -275,3 +276,3 @@ }

t.equal(items.length, 1);
t.deepEqual(items[0], {id: 'yo', range:5});
t.deepEqual(_(items[0]).omit('blob'), {id: 'yo', range:5});
var next = metas.pop().last;

@@ -286,4 +287,4 @@ t.ok(next, 'last evaluated key is not null');

t.equal(items.length, 2);
t.deepEqual(items[0], {id: 'yo', range:6});
t.deepEqual(items[1], {id: 'yo', range:7});
t.deepEqual(_(items[0]).omit('blob'), {id: 'yo', range:6});
t.deepEqual(_(items[1]).omit('blob'), {id: 'yo', range:7});
t.end();

@@ -290,0 +291,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc