diff --git a/services/docstore/app/js/MongoManager.js b/services/docstore/app/js/MongoManager.js index 76d9a88f14..09b93c7405 100644 --- a/services/docstore/app/js/MongoManager.js +++ b/services/docstore/app/js/MongoManager.js @@ -26,7 +26,9 @@ module.exports = MongoManager = { _id: ObjectId(doc_id.toString()), project_id: ObjectId(project_id.toString()) }, - filter, + { + projection: filter + }, callback ) }, @@ -39,7 +41,11 @@ module.exports = MongoManager = { if (!options.include_deleted) { query.deleted = { $ne: true } } - db.docs.find(query, filter).toArray(callback) + db.docs + .find(query, { + projection: filter + }) + .toArray(callback) }, getArchivedProjectDocs(project_id, callback) { @@ -106,7 +112,9 @@ module.exports = MongoManager = { doc_id: ObjectId(doc_id) }, { - version: 1 + projection: { + version: 1 + } }, function (error, doc) { if (error != null) { diff --git a/services/docstore/test/unit/js/MongoManagerTests.js b/services/docstore/test/unit/js/MongoManagerTests.js index ed0d2376dd..12fd3fba6c 100644 --- a/services/docstore/test/unit/js/MongoManagerTests.js +++ b/services/docstore/test/unit/js/MongoManagerTests.js @@ -60,7 +60,9 @@ describe('MongoManager', function () { _id: ObjectId(this.doc_id), project_id: ObjectId(this.project_id) }, - this.filter + { + projection: this.filter + } ) .should.equal(true) }) @@ -101,7 +103,9 @@ describe('MongoManager', function () { project_id: ObjectId(this.project_id), deleted: { $ne: true } }, - this.filter + { + projection: this.filter + } ) .should.equal(true) }) @@ -129,7 +133,9 @@ describe('MongoManager', function () { { project_id: ObjectId(this.project_id) }, - this.filter + { + projection: this.filter + } ) .should.equal(true) }) @@ -241,7 +247,12 @@ describe('MongoManager', function () { it('should look for the doc in the database', function () { return this.db.docOps.findOne - .calledWith({ doc_id: ObjectId(this.doc_id) }, { version: 1 }) + .calledWith( + { doc_id: ObjectId(this.doc_id) }, + { + projection: { version: 1 } + } + ) .should.equal(true) })