This commit is contained in:
Julian Lam
2015-06-05 13:33:58 -04:00
parent 5549280696
commit 96526a37a3
3 changed files with 34 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
nconf = require('nconf'),
session = require('express-session'),
_ = require('underscore'),
semver = require('semver'),
db, mongoClient;
_.mixin(require('underscore.deep'));
@@ -137,6 +138,7 @@
}
function createIndices() {
winston.info('[database] Checking database indices.')
async.parallel([
async.apply(createIndex, 'objects', {_key: 1, score: -1}, {background: true}),
async.apply(createIndex, 'objects', {_key: 1, value: -1}, {background: true, unique: true, sparse: true}),
@@ -164,6 +166,17 @@
});
};
module.checkCompatibility = function(callback) {
// For MongoDB, we need to ensure that the mongodb package is >= 2.0.0
var mongoPkg = require.main.require('./node_modules/mongodb/package.json'),
err = semver.lt(mongoPkg.version, '2.0.0') ? new Error('The `mongodb` package is out-of-date, please run `./nodebb setup` again.') : null;
if (err) {
err.stacktrace = false;
}
callback(err);
};
module.info = function(db, callback) {
db.stats({scale:1024}, function(err, stats) {
if(err) {