From 0faf38c65abd306b52fa28d36733260bc31e1e8d Mon Sep 17 00:00:00 2001 From: Bruno Bonnin Date: Wed, 24 Aug 2016 15:18:26 +0200 Subject: [PATCH] Support for mongodb 3.0 --- pom.xml | 2 +- src/main/resources/shell_extension.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 549b867..780c6fc 100644 --- a/pom.xml +++ b/pom.xml @@ -66,4 +66,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/shell_extension.js b/src/main/resources/shell_extension.js index fad2a23..876b363 100644 --- a/src/main/resources/shell_extension.js +++ b/src/main/resources/shell_extension.js @@ -52,7 +52,7 @@ function printTable(dbquery, fields, flattenArray) { // Flatten all the documents and get all the fields to build a table with all fields var docs = []; var createFieldSet = fields == null || fields.length == 0; - var fieldSet = new Set(fields); + var fieldSet = fields ? [].concat(fields) : []; //new Set(fields); while (iterator.hasNext()) { var doc = iterator.next(); @@ -60,22 +60,22 @@ function printTable(dbquery, fields, flattenArray) { docs.push(doc); if (createFieldSet) { for (var i in doc) { - if (doc.hasOwnProperty(i)) { - fieldSet.add(i); + if (doc.hasOwnProperty(i) && fieldSet.indexOf(i) === -1) { + fieldSet.push(i); } } } } - fields = [...fieldSet]; + fields = fieldSet; var header = "%table "; - fields.forEach(field => header += field + "\t") + fields.forEach(function (field) { header += field + "\t" }) print(header.substring(0, header.length - 1)); - docs.forEach(doc => { + docs.forEach(function (doc) { var row = ""; - fields.forEach(field => row += doc[field] + "\t") + fields.forEach(function (field) { row += doc[field] + "\t" }) print(row.substring(0, row.length - 1)); }); }