Skip to content

Added parameter to disable the collection of sample documents #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions getMongoData/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ as demonstrated for the local execution:

mongo --quiet --norc --eval "var _printJSON=true; var _ref = 'CS-XXXXX'" getMongoData.js > getMongoData-output.json

By default, the outut will include a sample document from each non-system collection. To disable this, include `_excludeDocs` argument as shown below:

mongo --quiet --norc --eval "var _printJSON=true; var _excludeDocs=true" getMongoData.js > getMongoData-output.json

### License

[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Expand Down
5 changes: 3 additions & 2 deletions getMongoData/getMongoData.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (DB.prototype.getRoles == null) {
}

// Taken from the >= 3.1.9 shell to capture print output
if (typeof print.captureAllOutput === "undefined") {
if (typeof print.captureAllOutput === "undefined") {
print.captureAllOutput = function (fn, args) {
var res = {};
res.output = [];
Expand Down Expand Up @@ -302,7 +302,7 @@ function printDataInfo(isMongoS) {
}
printInfo('Indexes',
function(){return db.getSiblingDB(mydb.name).getCollection(col).getIndexes()}, section);
if (col != "system.users") {
if (col != "system.users" && !_excludeDocs) {
printInfo('Sample document',
function(){
var lastValCursor = db.getSiblingDB(mydb.name).getCollection(col).find().sort({'$natural': -1}).limit(-1);
Expand Down Expand Up @@ -358,6 +358,7 @@ function printAuthInfo() {

if (typeof _printJSON === "undefined") var _printJSON = false;
if (typeof _ref === "undefined") var _ref = null;
if (typeof _excludeDocs === "undefined") var _excludeDocs = false;
var _output = [];
var _tag = ObjectId();
if (! _printJSON) {
Expand Down