Skip to content

Commit 205e792

Browse files
committed
INT-160 comment/no-op code that won't work under WiredTiger
1 parent 02c929b commit 205e792

File tree

3 files changed

+61
-56
lines changed

3 files changed

+61
-56
lines changed

scout-brain/lib/replicaset.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ Replicaset.prototype.config = function(fn) {
5454
// ```json
5555
// { "capped" : true, "size" : 41943040, "autoIndexId" : false }
5656
// ```
57-
Replicaset.prototype.collection = function(fn) {
58-
this.db.db('local').collection('system.namespaces').findOne({
59-
name: 'local.oplog.rs'
60-
}, function(err, doc) {
61-
if (err) return fn(err);
62-
if (!doc || !doc.options) return fn(boom.badRequest('Not a member of a replicaset.'));
63-
fn(null, doc.options);
64-
});
65-
return this;
66-
};
57+
58+
// TODO(kangas) INT-160 ADD TESTS, FIX FOR WIREDTIGER
59+
// Replicaset.prototype.collection = function(fn) {
60+
// this.db.db('local').collection('system.namespaces').findOne({
61+
// name: 'local.oplog.rs'
62+
// }, function(err, doc) {
63+
// if (err) return fn(err);
64+
// if (!doc || !doc.options) return fn(boom.badRequest('Not a member of a replicaset.'));
65+
// fn(null, doc.options);
66+
// });
67+
// return this;
68+
// };
6769

6870
// @api private
6971
Replicaset.prototype._status = function(fn) {

scout-server/lib/routes/_index.js

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@ var debug = require('debug')('scout-server:routes:_index');
33

44
module.exports = {
55
list: function(req, res, next) {
6-
req.db.collection('system.indexes', function(err, col) {
7-
col.find({
8-
ns: req.ns.toString()
9-
}).toArray(function(err, data) {
10-
if (err) return next(err);
11-
res.status(200).send(data);
12-
});
13-
});
6+
// TODO(kangas) INT-160 ADD TESTS, FIX FOR WIREDTIGER
7+
// req.db.collection('system.indexes', function(err, col) {
8+
// col.find({
9+
// ns: req.ns.toString()
10+
// }).toArray(function(err, data) {
11+
// if (err) return next(err);
12+
// res.status(200).send(data);
13+
// });
14+
// });
1415
},
1516
get: function(req, res, next) {
16-
var query = {
17-
ns: req.ns.toString(),
18-
name: req.param('index_name')
19-
};
17+
// TODO(kangas) INT-160 ADD TESTS, FIX FOR WIREDTIGER
18+
// var query = {
19+
// ns: req.ns.toString(),
20+
// name: req.param('index_name')
21+
// };
2022

21-
req.db.collection('system.indexes').findOne(query, function(err, data) {
22-
if (err) return next(err);
23-
if (!data) {
24-
return next(boom.notFound('Index does not exist'));
25-
}
26-
res.status(200).send(data);
27-
});
23+
// req.db.collection('system.indexes').findOne(query, function(err, data) {
24+
// if (err) return next(err);
25+
// if (!data) {
26+
// return next(boom.notFound('Index does not exist'));
27+
// }
28+
// res.status(200).send(data);
29+
// });
2830
},
2931
destroy: function(req, res, next) {
3032
if (req.param('index_name') === '*') {
@@ -43,35 +45,36 @@ module.exports = {
4345
});
4446
},
4547
create: function(req, res, next) {
46-
var field = req.body.field,
47-
options = req.body.options || {};
48+
// TODO(kangas) INT-160 ADD TESTS, FIX FOR WIREDTIGER
49+
// var field = req.body.field,
50+
// options = req.body.options || {};
4851

49-
if (!field) {
50-
return next(boom.badRequest('No field specified.'));
51-
}
52+
// if (!field) {
53+
// return next(boom.badRequest('No field specified.'));
54+
// }
5255

53-
if (typeof options !== 'object') {
54-
return next(boom.badRequest('options must be an object'));
55-
}
56+
// if (typeof options !== 'object') {
57+
// return next(boom.badRequest('options must be an object'));
58+
// }
5659

57-
req.db.createIndex(req.ns.collection, field, options, function(err, name) {
58-
if (err) {
59-
if (err.message.indexOf('bad index key pattern') > -1) {
60-
return next(boom.badRequest('Invalid index key pattern `' + JSON.stringify(field) + '`. Should be {key: [1|-1]}'));
61-
}
62-
return next(err);
63-
}
60+
// req.db.createIndex(req.ns.collection, field, options, function(err, name) {
61+
// if (err) {
62+
// if (err.message.indexOf('bad index key pattern') > -1) {
63+
// return next(boom.badRequest('Invalid index key pattern `' + JSON.stringify(field) + '`. Should be {key: [1|-1]}'));
64+
// }
65+
// return next(err);
66+
// }
6467

65-
req.db.collection('system.indexes', function(err, col) {
66-
col.findOne({
67-
ns: req.ns.toString(),
68-
name: name
69-
}, function(err, doc) {
70-
if (err) return next(err);
71-
res.status(201).send(doc);
72-
});
73-
});
74-
});
68+
// req.db.collection('system.indexes', function(err, col) {
69+
// col.findOne({
70+
// ns: req.ns.toString(),
71+
// name: name
72+
// }, function(err, doc) {
73+
// if (err) return next(err);
74+
// res.status(201).send(doc);
75+
// });
76+
// });
77+
// });
7578
},
7679
update: function(req, res, next) {
7780
var field = req.body.field,

scout-server/lib/routes/database.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ var boom = require('boom'),
99
debug = require('debug')('scout-server:routes:database');
1010

1111
function getCollectionNames(req, fn) {
12-
req.db.collection('system.namespaces').find({}).toArray(function(err, data) {
12+
req.db.listCollections().toArray(function(err, data) {
1313
if (err) return fn(err);
1414

1515
if (!data) {
1616
return fn(boom.notAuthorized('not authorized to view collections for this database'));
1717
}
1818

19-
debug('find(system.namespaces) returned', err, data);
19+
debug('listCollections returned', err, data);
2020

2121
var names = data.filter(function(ns) {
2222
return !(ns.name.indexOf('$') >= 0 && ns.name.indexOf('.oplog.$') < 0);

0 commit comments

Comments
 (0)