Skip to content

Commit cc6f410

Browse files
committed
Conflicts: index.js
2 parents f4bfba6 + 1387fea commit cc6f410

File tree

2 files changed

+41
-44
lines changed

2 files changed

+41
-44
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Like this: `"plugins": ["serverless-dynamodb-local"]`
2929

3030
## Starting Dynamodb Local
3131

32-
In your project root run:
32+
In your project root run (Note: Run this command first before any other command, since it will download the dynamodb local during the first run):
3333
`sls dynamodb start`
3434

3535
DynamoDB will process incoming requests until you stop it. To stop DynamoDB, type Ctrl+C in the command prompt window
@@ -47,7 +47,7 @@ All CLI options are optional:
4747
--create -c After starting dynamodb local, create dynamodb tables and run seeds. Check the "Manage tables and seeds" section for more information.
4848
```
4949

50-
All the above options can be added to s-function.json to set default configuration: e.g
50+
All the above options can be added to s-project.json to set default configuration: e.g
5151

5252
```json
5353
"custom": {
@@ -129,10 +129,6 @@ Open a browser and go to the url http://localhost:8000/shell to access the web s
129129

130130
Note: Default port: 8000 and if you change the port, change it accordingly in usage
131131

132-
## Coming up
133-
134-
* Allow to create tables & run seeds remotely with a simple set of commands.
135-
136132
## Links
137133

138134
* [Dynamodb local documentation](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html)

index.js

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ module.exports = function (S) { // Always pass in the ServerlessPlugin Class
2424
*/
2525
registerActions() {
2626

27-
S.addAction(this._tables.bind(this), {
28-
handler: 'table',
27+
S.addAction(this.table.bind(this), {
28+
handler: 'dynamodbTable',
2929
description: 'New dynamodb table template',
3030
context: 'dynamodb',
3131
contextAction: 'table',
@@ -39,14 +39,14 @@ module.exports = function (S) { // Always pass in the ServerlessPlugin Class
3939
description: 'Create dynamodb tables and run seeds'
4040
}]
4141
});
42-
S.addAction(this._removeDynamodb.bind(this), {
43-
handler: 'remove',
42+
S.addAction(this.remove.bind(this), {
43+
handler: 'dynamodbRemove',
4444
description: 'Remove dynamodb local database. This is needed if the installed version is currupted or needs to be upgraded.',
4545
context: 'dynamodb',
4646
contextAction: 'remove'
4747
});
48-
S.addAction(this._startDynamodb.bind(this), {
49-
handler: 'start',
48+
S.addAction(this.start.bind(this), {
49+
handler: 'dynamodbStart',
5050
description: 'Start dynamodb local database',
5151
context: 'dynamodb',
5252
contextAction: 'start',
@@ -96,49 +96,50 @@ module.exports = function (S) { // Always pass in the ServerlessPlugin Class
9696
* - You can also access other Project-specific data @ this.S Again, if you mess with data on this object, it could break everything, so make sure you know what you're doing ;)
9797
*/
9898

99-
_removeDynamodb() {
99+
remove() {
100100
return dynamodb.remove();
101101
}
102102

103-
_tables(evt) {
104-
let options = evt.options,
105-
config = S.getProject().custom.dynamodb,
106-
table = config && config.table || {},
107-
rootPath = S.getProject().getRootPath(),
108-
tablesPath = rootPath + '/' + (table.dir || 'dynamodb'),
109-
suffix = table.suffix || '',
110-
prefix = table.prefix || '';
103+
table(evt) {
104+
return new BbPromise(function (resolve, reject) {
105+
let options = evt.options,
106+
config = S.getProject().custom.dynamodb,
107+
table = config && config.table || {},
108+
rootPath = S.getProject().getRootPath(),
109+
tablesPath = rootPath + '/' + (table.dir || 'dynamodb'),
110+
suffix = table.suffix || '',
111+
prefix = table.prefix || '';
111112

112-
if (options.new) {
113-
return tables.newTemplate(options.new, tablesPath);
114-
} else if (options.create) {
115-
return tables.create(tablesPath, {
116-
prefix: prefix,
117-
suffix: suffix
118-
});
119-
}
113+
if (options.new) {
114+
tables.newTemplate(options.new, tablesPath).then(resolve, reject);
115+
} else if (options.create) {
116+
tables.create(tablesPath, {
117+
prefix: prefix,
118+
suffix: suffix
119+
}).then(resolve, reject);
120+
}
121+
});
120122
}
121123

122-
_startDynamodb(evt) {
123-
var self = this,
124-
config = S.getProject().custom.dynamodb,
125-
_spinner = SCli.spinner();
126-
127-
let options = _.merge({
128-
sharedDb: evt.options.sharedDb || true
129-
},
130-
evt.options,
131-
config && config.start
132-
);
124+
start(evt) {
125+
let self = this;
133126
return new BbPromise(function (resolve, reject) {
127+
let config = S.getProject().custom.dynamodb,
128+
options = _.merge({
129+
sharedDb: evt.options.sharedDb || true
130+
},
131+
evt.options,
132+
config && config.start
133+
),
134+
_spinner = SCli.spinner();;
134135
if (options.create) {
135-
dynamodb.start(options).then(function () {
136+
dynamodb.start(options).then(function () {
136137
console.log(""); // seperator
137-
self._tables(evt).then(resolve, reject);
138+
self.table(evt).then(resolve, reject);
138139
});
139140
} else {
140-
_spinner.start();
141-
dynamodb.start(options, _spinner).then(resolve, reject);
141+
_spinner.start()
142+
dynamodb.start(options).then(resolve, reject);
142143
}
143144
});
144145
}

0 commit comments

Comments
 (0)