Skip to content
This repository was archived by the owner on Dec 24, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/mongobq
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ program
.option('-u, --username <username>', 'specifies a mongodb username to authenticate')
.option('-p, --password <password>', 'specifies a mongodb password to authenticate')
.option('-d, --database <database>', 'specifies the name of the database')
.option('--ssl', 'specifies to use ssl for mongod connection')
.option('-c, --collection <collection>', 'specifies the collection to export')
.option('-f, --fields <field1[,field2]>', 'specifies a field or fields to include in the export')
.option('-q, --query <JSON>', 'provides a JSON document as a query that optionally limits the documents returned in the export', JSON.parse)
Expand Down Expand Up @@ -40,6 +41,7 @@ var opts = {
collection: program.collection,
username: program.username,
password: program.password,
ssl: program.ssl,
query: program.query || {},
fields: parseFields(program.schema, program.fields),
project: program.project,
Expand Down
9 changes: 7 additions & 2 deletions lib/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ var MongoClient = require('mongodb').MongoClient;
var SCHEMA = 'mongodb';

function buildMongodbUri(opts) {
var queryParams = '';
if (opts.ssl) {
queryParams += "?ssl=true";
}

if (opts.username) {
return util.format("%s://%s:%s@%s:%d/%s", SCHEMA, opts.username, opts.password, opts.host, opts.port, opts.database);
return util.format("%s://%s:%s@%s:%d/%s%s", SCHEMA, opts.username, opts.password, opts.host, opts.port, opts.database, queryParams);
} else {
return util.format("%s://%s:%d/%s", SCHEMA, opts.host, opts.port, opts.database);
return util.format("%s://%s:%d/%s%s", SCHEMA, opts.host, opts.port, opts.database, queryParams);
}
}

Expand Down