Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Commit 902619f

Browse files
committed
Bump node driver to 3.0.0
1 parent 58978cf commit 902619f

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

lib/fetch.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function attach(anything, done) {
2626
* @param {object} results results from async.auto
2727
*/
2828
function getIndexes(done, results) {
29-
var db = results.db;
29+
var client = results.client;
3030
var ns = mongodbNS(results.namespace);
31-
db.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection).indexes(function(err, indexes) {
31+
client.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection).indexes(function(err, indexes) {
3232
if (err) {
3333
done(err);
3434
}
@@ -46,13 +46,13 @@ function getIndexes(done, results) {
4646
* @param {object} results results from async.auto
4747
*/
4848
function getIndexStats(done, results) {
49-
var db = results.db;
49+
var client = results.client;
5050
var ns = mongodbNS(results.namespace);
5151
var pipeline = [
5252
{ $indexStats: { } },
5353
{ $project: { name: 1, usageHost: '$host', usageCount: '$accesses.ops', usageSince: '$accesses.since' } }
5454
];
55-
var collection = db.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection);
55+
var collection = client.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection);
5656
collection.aggregate(pipeline, { cursor: {}}).toArray(function(err, res) {
5757
if (err) {
5858
if (isNotAuthorizedError(err)) {
@@ -84,9 +84,9 @@ function getIndexStats(done, results) {
8484
*/
8585

8686
function getIndexSizes(done, results) {
87-
var db = results.db;
87+
var client = results.client;
8888
var ns = mongodbNS(results.namespace);
89-
db.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection).stats(function(err, res) {
89+
client.db(ns.database, { returnNonCachedInstance: true }).collection(ns.collection).stats(function(err, res) {
9090
if (err) {
9191
if (isNotAuthorizedError(err)) {
9292
debug('Not authorized to get collection stats. Returning default for indexSizes {}.');
@@ -124,13 +124,13 @@ function combineStatsAndIndexes(done, results) {
124124
* @param {String} namespace namespace for which to get indexes
125125
* @param {Function} done callback
126126
*/
127-
function getIndexDetails(db, namespace, done) {
127+
function getIndexDetails(client, namespace, done) {
128128
var tasks = {
129-
db: attach.bind(null, db),
129+
client: attach.bind(null, client),
130130
namespace: attach.bind(null, namespace),
131-
getIndexes: ['db', 'namespace', getIndexes],
132-
getIndexStats: ['db', 'namespace', getIndexStats],
133-
getIndexSizes: ['db', 'namespace', getIndexSizes],
131+
getIndexes: ['client', 'namespace', getIndexes],
132+
getIndexStats: ['client', 'namespace', getIndexStats],
133+
getIndexSizes: ['client', 'namespace', getIndexSizes],
134134
indexes: ['getIndexes', 'getIndexStats', 'getIndexSizes', combineStatsAndIndexes]
135135
};
136136

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ampersand-rest-collection": "^5.0.0",
3030
"async": "^1.5.2",
3131
"lodash": "^4.8.2",
32-
"mongodb": "^2.2.11",
32+
"mongodb": "^3.0.1",
3333
"mongodb-js-errors": "^0.2.1",
3434
"mongodb-ns": "^2.0.0",
3535
"triejs": "github:rueckstiess/triejs"
@@ -40,7 +40,7 @@
4040
"mocha": "^3.1.2",
4141
"mongodb-js-fmt": "^0.0.3",
4242
"mongodb-js-precommit": "^0.2.9",
43-
"mongodb-runner": "^3.3.2",
43+
"mongodb-runner": "^3.6.1",
4444
"pre-commit": "^1.1.2"
4545
}
4646
}

test/fetch.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ describe('fetch()', function() {
1414
this.slow(2000);
1515
this.timeout(10000);
1616

17-
var db;
17+
var client;
1818
var collection;
1919

2020
// connect and create collection with index
2121
before(function(done) {
22-
MongoClient.connect('mongodb://localhost:27017/test', function(err, _db) {
22+
MongoClient.connect('mongodb://localhost:27017/test', function(err, _client) {
2323
assert.ifError(err);
24-
db = _db;
25-
collection = db.collection('_test_index_fetch');
24+
client = _client;
25+
collection = _client.db('test').collection('_test_index_fetch');
2626
collection.ensureIndex({loc: '2d'}, {w: 1}, function(err2) {
2727
assert.ifError(err2);
2828
done();
@@ -36,7 +36,7 @@ describe('fetch()', function() {
3636
});
3737

3838
it('should connect to `localhost:27017` and get indexes', function(done) {
39-
fetch(db, 'test._test_index_fetch', function(err, res) {
39+
fetch(client, 'test._test_index_fetch', function(err, res) {
4040
assert.ifError(err);
4141
assert.equal(res[0].name, '_id_');
4242
assert.ok(_.isNumber(res[0].size));
@@ -47,7 +47,7 @@ describe('fetch()', function() {
4747
});
4848

4949
it('should populate an index collection', function(done) {
50-
fetch(db, 'test._test_index_fetch', function(err2, res) {
50+
fetch(client, 'test._test_index_fetch', function(err2, res) {
5151
assert.ifError(err2);
5252
var indexes = new IndexCollection(res, {parse: true});
5353
assert.equal(indexes.length, 2);
@@ -56,7 +56,7 @@ describe('fetch()', function() {
5656
});
5757

5858
it('should work with fetchIndexes() method', function(done) {
59-
var coll = new IndexCollection().fetchIndexes(db, 'test._test_index_fetch');
59+
var coll = new IndexCollection().fetchIndexes(client, 'test._test_index_fetch');
6060
coll.on('sync', function() {
6161
assert.equal(coll.length, 2);
6262
done();

0 commit comments

Comments
 (0)