diff --git a/lib/mongodb-backend.js b/lib/mongodb-backend.js index e3eb8de..ed8c32e 100644 --- a/lib/mongodb-backend.js +++ b/lib/mongodb-backend.js @@ -65,7 +65,7 @@ MongoDBBackend.prototype = { this.db.collection(this.prefix + this.removeUnsupportedChar(collName),function(err,collection){ if(err instanceof Error) return cb(err); // Excluding bucket field from search result - collection.findOne(searchParams, {_bucketname: 0},function(err, doc){ + collection.findOne(searchParams, {projection: {_bucketname: 0}},function(err, doc){ if(err) return cb(err); if(! _.isObject(doc) ) return cb(undefined,[]); doc = fixKeys(doc); @@ -88,7 +88,7 @@ MongoDBBackend.prototype = { this.db.collection(this.prefix + this.removeUnsupportedChar(collName),function(err,collection){ if(err instanceof Error) return cb(err); // Excluding bucket field from search result - collection.find(searchParams, {_bucketname: 0}).toArray(function(err,docs){ + collection.find(searchParams, {projection: {_bucketname: 0}}).toArray(function(err,docs){ if(err instanceof Error) return cb(err); if( ! docs.length ) return cb(undefined, []); diff --git a/package.json b/package.json index 496e6c6..b80c101 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,15 @@ "async": "^2.1.4", "bluebird": "^3.0.2", "lodash": "^4.17.3", - "mongodb": "^2.0.47", + "mongodb": "^3.1.1", "redis": "^2.2.5" }, "devDependencies": { - "mocha": "^3.2.0", - "chai": "^3.4.0" + "mocha": "^5.2.0", + "chai": "^4.1.2" }, "scripts": { - "test": "mocha test/runner.js --reporter spec", + "test": "mocha test/runner.js --reporter spec --exit", "cover": "istanbul cover -- _mocha test/runner.js --reporter spec" } } diff --git a/test/runner.js b/test/runner.js index 3092900..ed39689 100644 --- a/test/runner.js +++ b/test/runner.js @@ -7,7 +7,8 @@ describe('MongoDB - Default', function () { var self = this , mongodb = require('mongodb') - mongodb.connect('mongodb://localhost:27017/acltest',function(error, db) { + mongodb.connect('mongodb://localhost:27017/acltest',function(error, client) { + const db = client.db('acltest'); db.dropDatabase(function () { self.backend = new Acl.mongodbBackend(db, "acl") done() @@ -24,7 +25,8 @@ describe('MongoDB - useSingle', function () { var self = this , mongodb = require('mongodb') - mongodb.connect('mongodb://localhost:27017/acltest',function(error, db) { + mongodb.connect('mongodb://localhost:27017/acltest',function(error, client) { + const db = client.db('acltest'); db.dropDatabase(function () { self.backend = new Acl.mongodbBackend(db, "acl", true) done()