Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[minor] improved the `jitsu databases get interface`

  • Loading branch information...
commit e548924a7c322f7082c73f9117212e659623af36 1 parent e2e5dae
nicoreed authored
Showing with 34 additions and 6 deletions.
  1. +34 −6 lib/jitsu/commands/databases.js
View
40 lib/jitsu/commands/databases.js
@@ -64,9 +64,7 @@ databases.get = function (databaseName, callback) {
}
}
else {
- winston.info('Database name: ' + results.name);
- winston.info('Database type: ' + results.type);
- winston.info('Id: ' + results.metadata.id);
+ printDatabase(results);
}
callback();
});
@@ -87,9 +85,7 @@ databases.list = function (callback) {
else {
results.forEach(function (database) {
winston.info('');
- winston.info('Database name: ' + database.name);
- winston.info('Database type: ' + database.type);
- winston.info('Id: ' + database.metadata.id);
+ printDatabase(database);
});
if (results.length === 0) {
@@ -126,3 +122,35 @@ databases.destroy.usage = [
'Example usage:',
'jitsu databases destroy <database name>'
]
+
+var printDatabase = function (database) {
+ switch (database.type) {
+ case 'couch':
+ var subdomain = database.metadata.id.split('/')[1];
+ winston.info('Database name: ' + database.name);
+ winston.info('Database type: ' + database.type);
+ winston.info('Connection url: http://' + subdomain + '.couchone.com:5984');
+ break;
+
+ case 'mongo':
+ winston.info('Database name: ' + database.name);
+ winston.info('Database type: ' + database.type);
+ winston.info('Connection url: ' + database.metadata.config.MONGOHQ_URL);
+ break;
+
+ case 'redis':
+ var port = database.metadata.port,
+ password = database.metadata.password,
+ server = database.metadata.label.split('-')[0];
+
+ winston.info('Database name: ' + database.name);
+ winston.info('Database type: ' + database.type);
+ winston.info('Connection url: redis://nodejitsu:' + password+ '@' + server + '.redistogo.com:' + port + '/');
+ break;
+
+ default:
+ winston.info('Database name: ' + database.name);
+ winston.error('Unknown database type: ' + database.type);
+ break;
+ }
+}

0 comments on commit e548924

Please sign in to comment.
Something went wrong with that request. Please try again.