forked from mapbox/dyno
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (28 loc) · 1.08 KB
/
index.js
File metadata and controls
34 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var _ = require('underscore');
module.exports = Dyno;
function Dyno(c) {
var dyno = {};
var config = require('./lib/config')(c);
_(dyno).extend(config.dynamo);
_(dyno).extend(require('./lib/item')(config));
_(dyno).extend(require('./lib/query')(config));
_(dyno).extend(require('./lib/scan')(config));
_(dyno).extend(require('./lib/table')(config));
_(dyno).extend(require('./lib/batch')(config));
_(dyno).extend(require('./lib/describe')(config));
return dyno;
}
Dyno.multi = function(readConfig, writeConfig) {
if (!readConfig.region) throw badconfig('You must specify a read region');
if (!readConfig.table) throw badconfig('You must specify a read table');
if (!writeConfig.region) throw badconfig('You must specify a write region');
if (!writeConfig.table) throw badconfig('You must specify a write table');
var read = Dyno(readConfig);
var write = Dyno(writeConfig);
return require('./lib/multi')(read, write);
};
function badconfig(message) {
var err = new Error(message);
err.code = 'EBADCONFIG';
return err;
}